/* Implementation file for class GameDie A GameDie object represents a single game die. It has a set number of sides, each numbered from 1 to the number of sides, and it can be rolled, which results in a number between 1 and the number of sides. adapted from Astrachan's "A Computer Science Tapestry" 2nd edition, pp. 214, 217 by: Owen Astrachan adapted by: Sharon Tuttle last modified: 2015-08-26 */ #include "game_die.h" #include "randgen.h" using namespace std; /* construct a new die with the user-specified number of sides */ GameDie::GameDie(int desiredNumSides) { numRolls = 0; numSides = desiredNumSides; } /* return the die's number of sides */ int GameDie::getNumSides() const { return numSides; } /* return the die's number of times rolled */ int GameDie::getNumRolls() const { return numRolls; } /* roll this game die instance, and return the value of that roll uses: class RandGen */ int GameDie::roll() { RandGen gen; numRolls++; return gen.RandInt(1, numSides); }