Please send questions to
st10@humboldt.edu .
//**********************************************************
// declare a class Dice, representing a
// dice that can be randomly rolled as
// desired.
//
// adapted from Astrachan, "A Computer Science Tapestry",
// 2nd edition,
// McGraw Hill, pp. 214, 217
//
// adapted by: Sharon M. Tuttle
// last modified: 10-15-03
//******************************************************
class Dice
{
public:
// constructors
Dice(int nSides); // create an nSides-sided die
Dice(); // if they don't specify,
// we'll make it the
// standard 6-sided die
// accessor functions
int get_numSides() const;
int get_numRolls() const;
// mutator functions
void set_numSides(int newNumSides);
// (decided user CANNOT reset number of rolls...)
// additional public member functions
//---------------------------------------------
// Contract: roll : void -> int
// Purpose: returns a pseudo-random roll
// of this numSides-sided dice
// instance, returning a value
// between 1 and numSides (or,
// in the interval [1, numSides] )
//
// Examples: (OK, being random, this is tricky!)
// for a Dice instance:
// Dice myDie(3);
// myDie.roll() will return 1, 2, or 3
//----------------------------------------------
int roll();
private:
// member variables
int numSides; // # of sides on die
int numRolls; // # of times die rolled
// class-wide constants
static const int STD_NUM_SIDES = 6; // most common
// # of sides...
// implementation-dependent member functions
// (NOT for "public" use!)
};