Skip to content

Instantly share code, notes, and snippets.

@ChrisLundquist
Created October 10, 2012 02:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChrisLundquist/3862736 to your computer and use it in GitHub Desktop.
Save ChrisLundquist/3862736 to your computer and use it in GitHub Desktop.
public class Dice {
public:
Dice();
void roll();
int get_value();
string to_string();
IMAGE get_image();
private:
int value;
IMAGE image1;
IMAGE image2;
// ...
// constructor
Dice() {
value = 1;
image1 = Image.FromFile(filepath + "die-1.gif");
image2 = Image.FromFile(filepath + "die-2.gif");
// ...
}
void roll() {
value = Random(6) + 1;
}
int get_value() {
return value;
}
IMAGE get_image() {
if(value == 1) {
return image1;
} else if (value == 2) {
return image2;
}
// ...
else {
return image6;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment