After each move, we need to check if the game is over. The game ends when someone wins or it's a draw.
If/Else Statements:
Let you execute different code based on conditions.
Syntax:if (condition) { ... } else if (anotherCondition) { ... } else { ... }
Example:if (score > 100) { winner = true; } else { winner = false; }
For Our Game:
First, add a bool public gameOver; state variable to track if the game has ended.
Then update makeMove to check game state AFTER placing the piece:
• If checkWin() returns true → set gameOver = true;
• Else if checkDraw() returns true → set gameOver = true;
• Else → toggle turn with xTurn = !xTurn;
This ensures the turn only switches if the game continues.