...

/

Win Modules

Win Modules

Learn how can we check which player wins.

We'll cover the following...

What we have

Here is the snap of the gameEnds() function, which calls the checkWin() function.

bool gameEnds(char board[], char currentPlayer) {
if (checkWin(board, currentPlayer)) {
displayBoard(board);
cout << "\nPlayer " << currentPlayer << " wins!\n";
return true;
}
if (checkTie(board)) {
displayBoard(board);
cout << "\nThe game is a tie.\n";
return true;
}
return false;
}

Requirements of this module

We have to check if a player wins. We can create a bool function checkWin(), which will take two arguments, board and player, to check whether that player wins. There are 88 ...