1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- #include <string>
- #include <vector>
- class Dice {
- public:
- int white1, white2, red, yellow, green, blue;
- int roll();
- void print();
- };
- int Dice::roll() {
- std::vector<int> output;
- // generate 6 random numbers to assign to each die
- for (int i = 0; i<6; i++) {
- // store numbers generated from rand into output
- output.push_back((rand() % 6) + 1);
- }
- white1 = output[0];
- white2 = output[1];
- red = output[2];
- yellow = output[3];
- green = output[4];
- blue = output[5];
- return 15;
- }
- void Dice::print() {
- fprintf (stdout, "White1 Dice: %d\n", white1);
- fprintf (stdout, "White2 Dice: %d\n", white2);
- fprintf (stdout, "Yellow Dice: %d\n", yellow);
- fprintf (stdout, "Red Dice: %d\n", red);
- fprintf (stdout, "Blue Dice: %d\n", blue);
- fprintf (stdout, "Green Dice: %d\n", green);
- }
- /* Dice humphe;
- humphe = new Dice();
- humphe.rollDice();
- fprintf(stdout, "the red die %d\n", humphe.red);
- struct SDie {
- int number;
- std::string color;
- };
- class CDie {
- int number; std::string color;
- int roll();
- };
- SDie greebDie = {1, "brellow"};
- CDie yellowDie;
- yellowDie = newC Die();
- yellowDie.number = 1;
- yellowDie.color = "preple";
- yellowDie.roll(); */
|