// 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 numSides; // # sides on die static bool isInitialized; // for 'per-class' initialization }; #endif /* _DIE_H not defined */