Implements the TicTacToe mini-game.
More...
#include <minigames.h>
Implements the TicTacToe mini-game.
The TicTacToe class allows two players (or a player and the computer) to play a game of TicTacToe.
◆ checkForWin()
| bool TicTacToe::checkForWin |
( |
| ) |
|
Checks if there is a winner.
Check if there is a winner in TicTacToe.
- Returns
- True if there is a winner, otherwise false.
-
True if there is a winner, false otherwise.
Checks all rows, columns, and diagonals for three matching symbols ('X' or 'O').
◆ computerTurn()
| void TicTacToe::computerTurn |
( |
| ) |
|
Handles the computer's move.
Handle the computer's turn in TicTacToe.
The computer randomly selects an empty square to place its 'O'.
◆ delayTurn()
| void TicTacToe::delayTurn |
( |
| ) |
|
◆ getGameName()
| std::string TicTacToe::getGameName |
( |
| ) |
|
|
overridevirtual |
Gets the name of the game.
Get the name of the TicTacToe game.
- Returns
- A string representing the name of the game.
Implements Game.
◆ getPlayerMove()
| bool TicTacToe::getPlayerMove |
( |
int & |
row, |
|
|
int & |
col |
|
) |
| |
◆ getSquare()
| char TicTacToe::getSquare |
( |
int |
row, |
|
|
int |
col |
|
) |
| const |
Gets the value of a specific square on the board.
Get the value at a specific square on the TicTacToe board.
- Parameters
-
| row | The row of the square. |
| col | The column of the square. |
- Returns
- The character at the specified position on the board.
- Parameters
-
| row | The row of the square (0-indexed). |
| col | The column of the square (0-indexed). |
- Returns
- The character ('X', 'O', or ' ') at the specified square.
◆ handlePlayerTurn()
| bool TicTacToe::handlePlayerTurn |
( |
| ) |
|
◆ isGameOver()
| bool TicTacToe::isGameOver |
( |
int |
moveCount | ) |
|
◆ isValidMove()
| bool TicTacToe::isValidMove |
( |
int |
row, |
|
|
int |
col |
|
) |
| |
◆ makeMove()
| void TicTacToe::makeMove |
( |
int |
row, |
|
|
int |
col, |
|
|
char |
symbol |
|
) |
| |
◆ playerMove()
| void TicTacToe::playerMove |
( |
int |
row, |
|
|
int |
col |
|
) |
| |
Handles the player's move.
Handle the player's move in TicTacToe.
- Parameters
-
| row | The row of the square where the player wants to move. |
| col | The column of the square where the player wants to move. |
| row | The row where the player wants to place their 'X' (1-indexed). |
| col | The column where the player wants to place their 'X' (1-indexed). |
◆ printBoard()
| void TicTacToe::printBoard |
( |
| ) |
|
Prints the TicTacToe board.
Print the current state of the TicTacToe board.
Displays the current state of the TicTacToe board, showing the positions of 'X', 'O', and empty spaces.
◆ processComputerTurn()
| bool TicTacToe::processComputerTurn |
( |
| ) |
|
◆ setBoard()
| void TicTacToe::setBoard |
( |
char |
newBoard[3][3] | ) |
|
◆ start()
| bool TicTacToe::start |
( |
| ) |
|
|
overridevirtual |
Starts the TicTacToe game.
- Returns
- True if the game was completed successfully, otherwise false.
Implements Game.
The documentation for this class was generated from the following files: