|
|
|
|
|
|
|
CardType tempCard; // Temporary card
CardType firstCard; // First card in onTable
// Remove and save first card
onTable.RemoveTop(firstCard);
// Move second card
onTable.RemoveTop(tempCard);
discardPile.InsertTop(tempCard);
// Move third card
onTable.RemoveTop(tempCard);
discardPile.InsertTop(tempCard);
// Restore first card
onTable.InsertTop(firstCard);
} |
|
|
|
|
|
|
|
|
The Driver We have now designed and implemented all the objects responsible for playing the solitaire game. All that remains is to write the toplevel algorithm (the driver). |
|
|
|
|
|
|
|
|
Create playeran object of type Player
Set gamesWon = 0
Prompt for number of games to be played
Read numberOfGames
Prompt for number of shuffles
Read numberOfShuffles
Prompt for random number seed
Read seed
Use seed to initialize the random number generator
FOR gamesPlayed going from 1 through numberOfGames
player.PlayGame(numberOfShuffles, won)
IF won
Increment gamesWon
Print numberOfGames
Print gamesWon |
|
|
|
|
|
|