A simple 2-player Tic Tac Toe game built using Java. This project is a great way to understand basic programming concepts like arrays, loops, conditionals, and method design.
- 🧑🤝🧑 Two-player gameplay (Player X vs Player O)
- ✅ Input validation (prevents overwriting moves)
- 🧠 Win detection (rows, columns, diagonals)
- 🤝 Draw detection
- 🖥️ Clean console-based UI
- Java (Core Java)
- Scanner for user input
- Arrays for board representation
TicTacToe.java
- Clone the repository:
git clone https://github.com/your-username/tic-tac-toe-java.git- Navigate to the project folder:
cd tic-tac-toe-java- Compile the Java file:
javac TicTacToe.java- Run the program:
java TicTacToe- The game is played on a 3x3 grid.
- Players take turns entering row and column values.
- Example input:
0 0 → Top-left corner
1 1 → Center
2 2 → Bottom-right
- First player to align 3 marks (row/column/diagonal) wins.
- If all 9 moves are filled with no winner → Draw.
- 2D Arrays
- Loops and Conditionals
- Method Decomposition
- Game Logic Design
- Basic Input Handling
- Add GUI (Java Swing / JavaFX)
- Add Single Player Mode (AI)
- Improve UI with better formatting
- Add replay option
Feel free to fork this repo, improve it, and create a pull request!
If you have any suggestions or feedback, feel free to reach out!
⭐ If you like this project, consider giving it a star!