|
|
|
|
|
|
|
// Precondition:
// player == A or B
// && gameNumber and numOfWins are assigned
// Postcondition:
// A winning message, including player and gameNumber, has
// been written
// && numOfWins == numOfWins@entry + 1
{
cout < Player < player < has won game number
< gameNumber < . < endl;
numOfWins++;
}
//******************************************************************
void PrintBigWinner( /* in */ int winsForA, // A's win count
/* in */ int winsForB ) // B's win count
// Prints number of wins for each player and the
// overall winner (or tie)
// Precondition:
// winsForA and winsForB are assigned
// Postcondition:
// The values of winsForA and winsForB have been output
// && A message indicating the overall winner (or a tie) has been
// output
{
cout < endl;
cout < Player A has won < winsForA < games. < endl;
cout < Player B has won < winsForB < games. < endl;
if (winsForA > winsForB)
cout < Player A has won the most games. < endl;
else if (winsForB > winsForA)
cout < Player B has won the most games. < endl;
else
cout < Players A and B have tied. < endl;
} |
|
|
|
|
|
|
|
|
Testing: We tested the Game program with the following files. They are listed side by side so that you can see the pairs that made up each game. Note that each combination of R, S, and P is used at least once. In addition, there is an erroneous play character in each file. |
|
|
|
|
|