#include "dice.h"
// implementation of dice class
Dice::Dice(int sides)
// postcondition: all private fields initialized
{
myRollCount = 0;
mySides = sides;
}
int Dice::roll()
// postcondition: number of rolls updated
// random 'die' roll returned
{
myRollCount = myRollCount + 1; // update # of times die rolled
return myGenerator.RandInt(1,mySides); // in range [1..mySides]
}
int Dice::numSides()
// postcondition: return # of sides of die
{
return mySides;
}
int Dice::numRolls()
// postcondition: return # of times die has been rolled
{
return myRollCount;
}