dice.cpp 659 B

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