// Die.h Dave Reed (based on code by Owen Astrachan) // // A class for simulating an N-sided die. // // Die(int sides) -- constructor, with the number of die sides specified // (a default value of 6 is assumed if not specified) // int roll() -- returns the random "roll" of the die, a uniformly // distributed random number between 1 and # sides // int numSides() -- access function, returns # of sides // int numRolls() -- access function, returns # of times Roll called // for that particular Die #ifndef _DIE_H #define _DIE_H #include using namespace std; class Die { public: Die(int sides = 6); int roll(); int numSides() const; int numRolls() const; private: int rollCount; // # times die rolled int numberSides; // # sides on die static bool isInitialized; // for 'per-class' initialization }; #endif /* _DIE_H not defined */