dice.cpp 658 B

123456789101112131415161718192021
  1. #include "dice.h"
  2. Dice::Dice(){
  3. srand(time(NULL));
  4. roll();
  5. }
  6. int Dice::roll() {
  7. // generate 6 random numbers to assign to each die
  8. for (int i = 0; i<colors; i++) {
  9. // store numbers generated from rand into output
  10. dice.push_back((rand() % 6) + 1);
  11. }
  12. return 15;
  13. }
  14. void Dice::print() {
  15. fprintf (stdout, "White1 Dice: %d\n", dice[white1]);
  16. fprintf (stdout, "White2 Dice: %d\n", dice[white2]);
  17. fprintf (stdout, "Yellow Dice: %d\n", dice[yellow]);
  18. fprintf (stdout, "Red Dice: %d\n", dice[red]);
  19. fprintf (stdout, "Blue Dice: %d\n", dice[blue]);
  20. fprintf (stdout, "Green Dice: %d\n", dice[green]);
  21. }