|
|
|
|
|
|
|
#include cardpile.h
#include carddeck.h
#include bool.h
class Player
{
public:
void PlayGame( /* in */ int numberOfShuffles,
/* out */ Boolean& won );
// Precondition:
// numberOfShuffles is assigned
// Postcondition:
// After deck has been shuffled numberOfShuffles times,
// one game of solitaire has been played
// && won == TRUE, if the game was won
// == FALSE, otherwise
private:
CardDeck deck;
CardPile onTable;
CardPile discardPile;
void TryRemove();
void MoveFour();
void MoveTwo();
};
#endif |
|
|
|
|
|
|
|
|
The Player class has one public operation, PlayGame, that plays one game of solitaire and reports whether the game was won or lost. The private part of the class consists of three class objectsdeck, onTable, and discardPileand three private member functions. These helper functions are used in the playing of the game and are not accessible to clients of the class. |
|
|
|
|
|