Tic Tac Toe Game
Tic Tac Toe Game
import java.util.Scanner;
while (gameOn) {
System.out.println(currentPlayer + "'s turn. Enter row and column (1-
3): ");
int row = keyboard.nextInt() - 1;
int col = keyboard.nextInt() - 1;
if (TicTacToeMethods.checkWin(grid)) {
System.out.println("Game over! " + currentPlayer + " wins!");
gameOn = false;
} else if (isDraw(grid)) {
System.out.println("Game over! It's a draw!");
gameOn = false;
} else {
currentPlayer = currentPlayer.equals("X") ? "O" : "X";
}
} else {
System.out.println("Invalid move. Try again.");
}
}
}