Skip to content

A simple Tic Tac Toe terminsl game implemented in Java. Game can be played multiple times by choosing "Play Again" option. If a player gets 3 marks in a row horizontally, vertically, or diagonally, then he wins. The game ends when all 9 squares are filled. The game has error handling for invalid inputs and occupied squares.

Notifications You must be signed in to change notification settings

NikylS007/Tic-Tac-Toe-Game-in-Java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tic Tac Toe Game in Java

This is a simple implementation of the classic Tic Tac Toe game in Java using the Java programming language. The game is played on a 3x3 grid where two players, X and O, take turns marking the grid with their respective symbols. The first player to get 3 of their marks in a row (horizontally, vertically, or diagonally) wins the game. If all 9 squares are filled and there is no winner, the game is a draw.

Requirements

  • Java 8 or higher
  • A Java development environment such as Eclipse or IntelliJ

How to Run the Code

  1. Clone or download the repository to your local machine
  2. Open the project in your Java development environment
  3. Run the main class
  4. Follow the on-screen instructions to play the game

Code Structure

The code consists of the following classes and functions:

  • The main class(src -> main) that contains the main function. It manages the overall flow of the game, asking the user whether they want to play the game or exit.
  • The Game function sets up the game, displays the game instructions, and handles the game play.
  • The check function checks if any player has won the game.
  • The XOGamePass function displays the current state of the game board.

Limitations

  • The game is only for two players and does not support more players.
  • The game does not have an AI component to play against the computer.

Contributions

If you find any bugs or have suggestions for improvements, feel free to open an issue or make a pull request.

Conclusion

This Tic Tac Toe game is a simple implementation of the classic game in Java. It provides a basic understanding of how the game works and how it can be implemented using the Java programming language. Feel free to use the code as a starting point for your own Tic Tac Toe game or as a learning tool for Java programming.

About

A simple Tic Tac Toe terminsl game implemented in Java. Game can be played multiple times by choosing "Play Again" option. If a player gets 3 marks in a row horizontally, vertically, or diagonally, then he wins. The game ends when all 9 squares are filled. The game has error handling for invalid inputs and occupied squares.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages