|
@@ -1,56 +1,21 @@
|
|
-#include <string>
|
|
|
|
-#include <vector>
|
|
|
|
-class Dice {
|
|
|
|
- public:
|
|
|
|
- int white1, white2, red, yellow, green, blue;
|
|
|
|
- int roll();
|
|
|
|
- void print();
|
|
|
|
-};
|
|
|
|
|
|
+#include "dice.h"
|
|
|
|
+Dice::Dice(){
|
|
|
|
+ srand(time(NULL));
|
|
|
|
+}
|
|
int Dice::roll() {
|
|
int Dice::roll() {
|
|
std::vector<int> output;
|
|
std::vector<int> output;
|
|
// generate 6 random numbers to assign to each die
|
|
// generate 6 random numbers to assign to each die
|
|
- for (int i = 0; i<6; i++) {
|
|
|
|
|
|
+ for (int i = 0; i<colors; i++) {
|
|
// store numbers generated from rand into output
|
|
// 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];
|
|
|
|
|
|
+ dice.push_back((rand() % 6) + 1);
|
|
|
|
+ }
|
|
return 15;
|
|
return 15;
|
|
}
|
|
}
|
|
void Dice::print() {
|
|
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(); */
|
|
|
|
|
|
+ fprintf (stdout, "White1 Dice: %d\n", dice[white1]);
|
|
|
|
+ fprintf (stdout, "White2 Dice: %d\n", dice[white2]);
|
|
|
|
+ fprintf (stdout, "Yellow Dice: %d\n", dice[yellow]);
|
|
|
|
+ fprintf (stdout, "Red Dice: %d\n", dice[red]);
|
|
|
|
+ fprintf (stdout, "Blue Dice: %d\n", dice[blue]);
|
|
|
|
+ fprintf (stdout, "Green Dice: %d\n", dice[green]);
|
|
|
|
+}
|