0% found this document useful (0 votes)
23 views

Tic Tac Toe

..

Uploaded by

akgillmen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Tic Tac Toe

..

Uploaded by

akgillmen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

MEDICINE MANAGEMNT

A Mini Project (BCSE0252) Report Submitted


for 2rd Year
Bachelor of Technology

In
COMPUTER SCIENCE AND ENGINEERING (ARTIFICIAL
INTELLIGENCE)

By

AMEYA ATREYA (Roll No. 2301331520025)


AMIT KUMAR (Roll No. 2301331520026)
ANURAG VERMA (Roll No. 23013331520038)

Under the Supervision of


Asso. Prof. (Dr.) SARIKA AGARWAL
Associate Professor, Computer Science & Engineering(Artificial Intelligence)

Computer Science & Engineering(Al) Department


School of Emerging Technologies
NOIDA INSTITUTE OF ENGINEERING AND TECHNOLOGY, GREATER
NOIDA
(An Autonomous Institute)
Affiliated to
DR. A.P.J. ABDUL KALAM TECHNICAL UNIVERSITY, LUCKNOW
November, 2024

1
DECLARATION
We hereby declare that the work presented in this report entitled “TIC TAC TOE GAME
USING JAVA (OOP)” was carried out by us. We have not submitted the matter embodied
in this report for the award of any other degree or diploma of any other University or
Institute. We have given due credit to the original authors/sources for all the words, ideas,
diagrams, graphics, computer programs, experiments, and results that are not our original
contribution. We have used quotation marks to identify verbatim sentences and given credit
to the original authors/sources.
We affirm that no portion of our work is plagiarized, and the experiments and results reported
in the report are not manipulated. In the event of a complaint of plagiarism and the
manipulation of the experiments and results, we shall be fully responsible and answerable.

Name : Ameya Atreya


Roll Number : 2301331520025

Name : Amit Kumar


Roll Number : 2301331520026

Name : Anurag Verma


Roll Number : 2301331520038

2
Table of Contents
1. Abstract
2. Introduction
3. Objective
4. Technologies Used
5. Game Logic
6. Object-Oriented Design
7. Graphical User Interface (GUI)
8. Key Features
9. Challenges Faced
10. Conclusion
11. Future Work
12. References

3
Abstract
Tic Tac Toe – a game that has entertained millions over generations – may seem deceptively
simple, but developing it provides an excellent opportunity to explore fundamental concepts
of programming and user interface design. This report explores the development of a Tic Tac
Toe game using Java, integrating not just game logic but a user-friendly graphical interface
and object-oriented design principles. The project is an interactive learning journey that not
only results in a playable game but also showcases how software can combine logic, design,
and usability in a seamless way.

4
1. Introduction
Tic Tac Toe, also known as Noughts and Crosses, is a timeless game known for its
simplicity, yet it also involves strategic decision-making and problem-solving. Played on a
3x3 grid, the game's objective is to place three of one’s marks ("X" or "O") in a row, either
horizontally, vertically, or diagonally. Although the game’s rules are simple, creating a
playable version of the game involves a variety of concepts that are crucial to software
development.
This report discusses how the simple game of Tic Tac Toe was transformed into an
interactive, visually engaging experience using Java programming, Swing for the GUI, and
object-oriented design. The aim was to not only implement the game but also demonstrate
best practices in software development, user interface design, and modular code structuring.

2. Objective
The goal of this project was to create an engaging and interactive Tic Tac Toe game that
could be easily played by anyone. The game was developed with the following objectives:
 Create an Interactive GUI: Use Java Swing to create a user-friendly graphical
interface where players can easily place their marks.
 Implement Robust Game Logic: Ensure that the game logic correctly handles player
turns, detects winners, handles draws, and provides dynamic feedback.
 Enhance User Experience: Focus on creating an intuitive experience where users
can click to play, receive real-time updates, and enjoy a smooth gaming experience.
 Utilize Object-Oriented Programming Principles: Design the game using OOP
principles to keep the code modular, maintainable, and scalable.
The overall aim was to design a game that was easy for anyone to pick up and play, from
casual players to those seeking a strategic challenge.

3. Technologies Used
Several tools and technologies were used in the development of the Tic Tac Toe game:
 Java: As the main programming language, Java provided the structure and logic
required to implement the game. It was chosen for its object-oriented capabilities,
which facilitated modular development, and its ability to integrate easily with
graphical components.
 Swing: A GUI toolkit provided by Java, Swing enabled the creation of a custom
interface for the game. It provided components like buttons, labels, and panels that
were crucial for displaying the game board, handling user inputs, and managing
dynamic content.
 Eclipse IDE: Eclipse was the development environment used for writing, debugging,
and testing the code. Its features such as auto-completion, error detection, and
integrated testing tools significantly sped up the development process.

5
 JDK 8: The Java Development Kit (JDK) 8 was used to compile and run the program.
It was fully compatible with both Swing and Eclipse and allowed for efficient
development and execution.
These technologies worked in harmony to build a functional and visually appealing game.

4. Game Logic
The game logic is the core component that drives the gameplay. While the rules of Tic Tac
Toe are straightforward, implementing them programmatically required attention to detail.
Key components of the game logic include:
1. Player Turns: The game alternates turns between two players (or one player and the
AI, if implemented). Players take turns clicking on the grid to place their respective
mark ("X" or "O").
2. Win Detection: After each move, the game checks whether any player has formed a
winning combination. This involves checking each row, column, and both diagonals
for three consecutive marks of the same player.
3. Draw Condition: If all nine cells are filled and no player has won, the game checks
for a draw. The game ends with a message announcing a draw.
4. Dynamic Feedback: The game continuously provides feedback to the players. It
shows whose turn it is, updates after every move, and announces the result when the
game ends.
This part of the project required meticulous testing to ensure that all possible game outcomes
(win, draw, continue) were handled correctly.

5. Object-Oriented Design
By applying Object-Oriented Programming (OOP) principles, the game was divided into
several classes, each representing a distinct part of the system. This made the code easier to
manage, debug, and extend. The classes include:
 TicTacToeGame: The main controller class that manages the game flow. It keeps
track of the current state, alternates player turns, and checks for winners.
 Board: The class that represents the 3x3 game grid. It manages the state of each cell
and checks for winning combinations.
 Player: The class that represents each player, storing information about the player’s
symbol ("X" or "O") and making decisions about where to place their mark.
 TicTacToeGUI: This class defines the graphical user interface of the game. It
updates the visual elements based on game progress, such as the board state and
whose turn it is.
OOP principles made the game modular and scalable, allowing for easy additions (e.g., AI
opponent, multiplayer functionality).

6
6. Graphical User Interface (GUI)
The GUI, designed using Java Swing, is a crucial aspect of the game. It makes the game
interactive and visually engaging. The key elements of the interface include:
 Grid Layout: A 3x3 grid of JButtons, where each button represents a cell on the Tic
Tac Toe board. Players click these buttons to place their mark in the selected cell.
 Turn Indicator: A JLabel displays whose turn it is, updating with every move to
guide the players.
 Game End Message: Once the game ends, either a victory message or a draw
message appears, announcing the result.
 Reset Button: A button allows players to reset the game and start a new round.
The simplicity of the interface allows players to focus on strategy while providing clear
visual feedback after every move.

7. Key Features
Several features make the Tic Tac Toe game more engaging and functional:
 Interactive Gameplay: The game responds instantly to player clicks, making it easy
for players to interact with the game.
 Smooth Turn Management: The game automatically alternates turns between
players, and it visually updates to show whose turn it is.
 Winner Detection: The game checks after each move for a winning combination and
announces the winner.
 Draw Detection: If the grid is filled and no player has won, the game announces a
draw.
 Replayability: Players can reset the game and start a new match immediately,
promoting continuous gameplay.
These features ensure that the game is not only functional but also enjoyable to play.

8. Challenges Faced
During the development of the Tic Tac Toe game, several challenges were encountered:
 UI Design: Designing a user interface that is both functional and visually appealing
required careful planning and iteration. The placement of buttons, updating labels, and
ensuring the interface was intuitive took time to perfect.
 Game Logic Testing: Ensuring the game’s logic was accurate and handling edge
cases (like detecting a win after every move) required extensive testing and
debugging.

7
 Cross-Platform Compatibility: The game was tested across different systems to
ensure that it would run smoothly on various platforms, as Java applications are often
subject to different display and behavior issues depending on the environment.
These challenges were overcome with a combination of good design practices, thorough
testing, and iterative development.

9. Conclusion
The Tic Tac Toe game developed in Java demonstrates how fundamental programming
concepts can come together to create a complete, interactive game. The application of object-
oriented design principles, efficient use of Swing for the GUI, and real-time game logic
create a smooth, engaging experience for users. This project not only strengthened
programming skills but also provided insights into game design and software development.

10. Future Work


While the game is complete, there are several exciting opportunities for future improvement:
 AI Opponent: Adding an AI player using algorithms like Minimax would allow for a
more challenging experience when playing solo.
 Visual Enhancements: The interface could be enhanced with animations for
winning, losing, or drawing, and sound effects could be added for further immersion.
 Customizable Rules: Adding features like larger boards (e.g., 4x4 grid) or different
win conditions would provide more gameplay variety.
 Multiplayer Mode: Implementing online multiplayer would allow users to play
against others across different devices.
These improvements would significantly increase the game's replayability and make it even
more enjoyable.

11. References
1. Head First Java
Sierra, Kathy, and Bates, Bert. Head First Java. O'Reilly Media, 2005.
This book was instrumental in teaching the basics of Java programming and object-
oriented design principles, which were key in developing the Tic Tac Toe game.
2. Java: The Complete Reference
Herbert Schildt. Java: The Complete Reference. McGraw-Hill, 2011.
A comprehensive guide to Java programming, this book was useful in implementing
the game's features and understanding Java's capabilities.
3. Design Patterns: Elements of Reusable Object-Oriented Software
Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides. Design Patterns.
Addison-Wesley, 1994.

8
This book introduced design patterns that helped in structuring the game’s object-
oriented design and ensuring maintainability and scalability.

You might also like