🎮 This is a simple Tic-Tac-Toe game implemented in the console.
👤 Oskar Kalbarczyk
🌐 GitHub: https://github.com/oskalbarczyk
📺 YouTube Channel: Code with Oskar
- Run the program.
- The game will display a 3x3 grid representing the Tic-Tac-Toe board.
- The first player is always 'O', and the second player is 'X'.
- The players take turns to choose a field they want to cover.
- When prompted, enter the number of the field you want to choose (1-9).
- The game will validate the move and update the board accordingly.
- The game will continue until a player wins or the board is full.
- The game will display "Game Over!" when it ends.
The game uses the numbers 1-9 to represent the fields on the board. The grid is displayed as follows:
|1|2|3| |4|5|6| |7|8|9|
When it's your turn, select the field number you want to cover. For example, if you want to cover the top-right corner, enter '3'.
The game checks for the following winning conditions:
- Rows: If a player covers all fields in a row, they win.
- Columns: If a player covers all fields in a column, they win.
- Diagonals: If a player covers all fields in a diagonal, they win.
To compile and run the project, ensure you have Java installed on your system. Then follow these steps:
- Save the code into a file named
Main.java
. - Open a command prompt or terminal window.
- Navigate to the directory where you saved the file.
- Compile the code by running the command:
javac Main.java
- Run the program using the command:
java Main
Enjoy playing Tic-Tac-Toe in the console! 🎉