< Previous | Contents | Next >
This function asks the player if he wants to go first, and returns the human’s piece based on that choice. As the great tradition of Tic-Tac-Toe dictates, the X goes first.
char humanPiece()
{
210 Chapter 6 n References: Tic-Tac-Toe
char go_first = askYesNo("Do you require the first move?"); if (go_first == ’y’)
{
cout << "\nThen take the first move. You will need it.\n"; return X;
}
else
{
cout << "\nYour bravery will be your undoing.. . I will go first.\n"; return O;
}