// token.h // A class to simulate playing tokens on a game board #ifndef _TOKEN_H #define _TOKEN_H #include #include "dice.h" class token { public: token(char name, int startPos, int winPos, int maxDiceRoll); bool move(); int getPos() const; char getName() const; private: char myName; int myPosition; int myWinningPos; dice myDice; }; token::token(char name, int startPos, int winPos, int maxDiceRoll) : myName(name), myPosition(startPos), myWinningPos(winPos), myDice(maxDiceRoll) { // all private variables initialized using initializer list } bool token::move() { int n = myDice.roll(); myPosition += n; if (myPosition >= myWinningPos) return true; else return false; } int token::getPos() const { return myPosition; } char token::getName() const { return myName; } #endif