
//  Die.cpp        Dave Reed        davereed@creighton.edu
/////////////////////////////////////////////////////////////

#include <ctime>
#include "Die.h"
using namespace std;

bool Die::isInitialized = false;

Die::Die(int sides)
// Results: all private fields are initialized     
{
    if (!isInitialized)
    {   
        isInitialized = true;       // only call srand once
        srand(unsigned(time(0)));    // randomize
    }
    rollCount = 0;
    numSides = sides;
}

int Die::Roll()
// Returns: a random 'die' roll (and roll count is incremented)    
{
    int dieRoll = rand()%numSides + 1;
    rollCount++;

    return dieRoll;
}

int Die::NumSides() const
// Returns: # of sides on the die     
{
    return numSides;
}

int Die::NumRolls() const
// Returns: # of times the die has been rolled     
{
    return rollCount;
}