A simple two-player console-based Tic-Tac-Toe game written in Java. The game includes input validation, win detection, and a turn-based system. Players take turns entering their moves, and the game announces the winner or a draw. Ideal for beginners learning Java basics and game logic.
- Two-player turn-based gameplay
- Input validation to prevent invalid moves
- Automatic win and draw detection
- Simple console-based UI
- Clone the repository:
git clone https://github.com/nurulashraf/java-tic-tac-toe.git
- Navigate to the project directory:
cd java-tic-tac-toe
- Compile the Java code:
javac src/TicTacToe.java
- Run the game:
java -cp src tictactoe.TicTacToe
- Run the program and follow the on-screen instructions.
- Players take turns inputting row and column numbers (0-2) to place their mark (
X
orO
). - The game will announce the winner or a draw when applicable.
This project is licensed under the MIT License. See the LICENSE
file for details.