The Java code implements a simple Tic-Tac-Toe game using Swing for the GUI. Tic-Tc-Toe is a Java-based project designed to help users play tic tac toe game through an intuitive Graphical User Interface (GUI). The game is played on a 3x3 grid. Players take turns clicking buttons to place their respective marks (X or O).
-
Graphical User Interface (GUI) Utilizes Java Swing (JFrame, JPanel, JButton, JLabel) for interactive elements. Provides a visually appealing 3x3 grid for gameplay.
-
Turn-based Gameplay: Alternates turn between Player X and Player O. Displays whose turn it is (X or O) using a JLabel at the top.
-
Interactive Buttons: Clicking on a button places the current player's mark (X or O). Buttons change color and text based on the player's turn.
-
Win Condition Detection: Checks after each move for win conditions: Three marks in a row (horizontal, vertical, diagonal). Declares the winner and disables further button clicks upon winning.
-
Tie Detection: Checks if all buttons are filled without a winner. Declares a tie game and disables further button clicks.
-
Initialization: Randomly determines which player starts first (X or O) using Random class.
-
Outcome Display: Updates a JLabel with messages indicating the game's current status: "X Turn" or "O Turn" for player turns. "X wins", "O wins", or "Tie" for game outcomes.
Follow these steps to set up and run the Tic-Tac-Toe project:
- Clone the Repository: Clone the GitHub repository to your local machine using the following command: sh Copy code git clone https://github.com/Amandeepkaur1804/Tictactoe.git
- Open the Project: Use an Integrated Development Environment (IDE) that supports Java to open the project.
- Run the Application: Locate the main Java file (TicTacToe.java) and run the application. This will launch the Tic-Tac-Toe GUI.
I want you to know that contributions to this project are welcome and encouraged. To contribute:
- Fork the repository on GitHub.
- Create a new branch with a descriptive name for your feature or bug fix.
- Make your changes and improvements to the code.
- Test your changes thoroughly.
- Create a pull request to merge your changes into the main repository.
Happy playing!