Java Game | Tic-Tac-Toe

Source Code Screenshots

Project Background

This project involved a scenario of taking over from another programmer to complete the build of a Tic-Tac-Toe game.

Tic-Tac-Toe involves two players taking turns to mark noughts or crosses on a 3x3 grid. The first player to place three of their marks in a horizontal, vertical or diagonal row wins.

Discovery

This game needed to be a simplified graphical version where a JPanel component needed to be implemented to create a canvas that would allow noughts and crosses to be painted on.

In the game, crosses always needed to begin. The game needed to check after each move whether a player had won. Players needed to restart the game by clicking any cell after the game ended with a winner or a draw.

The other programmer's unfinished source code was provided and included ‘TODO’ comments which hinted at the code that needed to be written.

Comments, explaining my approach and what the code does, needed to be included when adding additional code.

Design

A UML class diagram was created with the draw.io application to design each class and indicate the relationship between them.

Development

The game was written in Java and developed within the Eclipse IDE for Java Developers.

Testing

User acceptance testing was carried out to ensure the game functioned as intended.

Deployment

The source code was uploaded to a GitHub repository for this project.

Take a Closer Look

The screenshots below show what the game looks like in action.

Screens for User Interaction

Simplified Graphics

A screenshot of the simplified graphical game version

Crosses Begin

A screenshot of crosses beginning the game

Noughts Taking a Turn

A screenshot of the game after Noughts took a turn

Ending with a Win

A screenshot of the game ending with crosses who won

Ending in a Draw

A screenshot of the game ending in a draw

Top of page