< Previous | Contents | Next >

The announceWinner() Function

This function receives the winner of the game, the computers piece, and the humans piece. The function announces the winner or declares a tie.

void announceWinner(char winner, char computer, char human)

{

if (winner == computer)

{

cout << winner << "’s won!\n";

cout << "As I predicted, human, I am triumphant once more -- proof\n"; cout << "that computers are superior to humans in all regards.\n";

}


else if (winner == human)

{

cout << winner << "’s won!\n";

cout << "No, no! It cannot be! Somehow you tricked me, human.\n"; cout << "But never again! I, the computer, so swear it!\n";

}


else

{


}

}


cout << "It’s a tie.\n";

cout << "You were most lucky, human, and somehow managed to tie me.\n"; cout << "Celebrate.. . for this is the best you will ever achieve.\n";