______________________________
PBL
PROJECT REPORT
_______________________________
Project Title : Tic Tac Toe Game
Course : Data Structure & Algorithm
Department : Computer Science/IT
Class : BS-AI (3rd Semester)
Submitted by : Areeba Iftikhar, Muddasir Ali
Submitted to : Ms. Arooj Fatima
Submission Date : 10-12-2025
0
Table of Contents
1. Introduction ................................................................... 2
2. Objectives ...................................................................... 2
3. Tools and Technologies ................................................. 2
4. Class Design .................................................................. 3
5. Scope ............................................................................. 4
6. Game Logic .................................................................. 4
7. Flowchart ...................................................................... 5
8. Sample Output ............................................................... 6
9. Data Structure & Algorithm Concepts Used .............. 6
10. Project timeline ............................................................ 7
11. Conclusion ....................................................................
8
12. Future Enhancements ……………………................... 8
1
Project Report: Tic Tac Toe Game using
Data Structure & Algorithm in C++.
1. Introduction
This C++ code implements a classic game of Tic Tac
Toe, a simple yet engaging game for two players. The
game is designed using Data Structure & Algorithm
principles, with a base class Game and a derived class
TicTacToe. The TicTacToe class encapsulates the
game's logic, including the game board, player
switching, move validation, and win conditions. The
game is played on a 3x3 grid, where players take turns
marking a square with either an 'X' or an 'O'. The
game ends when one player gets three of their marks in
a row, column, or diagonal, or when all squares are
filled, resulting in a draw. This code provides a well-
structured and functional implementation of the game,
demonstrating key programming concepts and
techniques.
2. Objectives
2
The main objectives of this project are:
To understand and implement 2D arrays in C++.
To design a modular structure using user-defined
functions.
To develop a command-line user interface for
gameplay.
To implement game logic including:
o Player turn switching
o Win checking
o Draw checking
o Board display
To improve problem-solving and logical thinking in
programming
3. Tools and Technologies
Programming Language: C++
Compiler: g++ or any standard C++ compiler
Platform: Console (Command Line Interface)
4. Class Design
3
Class Name: Tic Tac Toe
Data Members:
char board[3][3]: 3x3 character array to represent the game
board.
char player: Tracks the current player ('X' or 'O').
5. Scope
The scope of this project includes:
Building a text-based two-player Tic Tac Toe game.
Implementing the game logic using DSA principles.
Providing basic input validation and turn-switching
logic.
6. Game Logic
4
The board is initialized with numbers 1 to 9.
Players take turns entering a slot number (1–9) to place
their symbol (X or O).
After each valid move, the program checks for a win
condition using check-Win().
If a win is detected, the game ends declaring the current
player as the winner.
If all 9 moves are used without a winner, the game ends
in a draw.
Invalid inputs (occupied slots) prompt the user to try
again.
7. Flowchart
Start
5
Display Board
Player 1 Input
Check
Winner or Draw
No
No
Player 2 Input
Check
Ye
Winner or Draw
Ye
Display Result
End
8. Sample Output
123
6
456
789
Player X, enter your move (1-9): 5
123
4X6
789
...
Player X wins..
9. Flow of the Program
1. Start the game
7
2. Initialize the 3×3 board
3. Display board with numbered positions
4. Player X starts the game
5. Player enters a number from 1–9
6. Input is validated
7. Board updates
8. Check if the player won
9. If not, check for draw
10. Switch players X ↔ O
11. Repeat until game ends
12. Display winner or draw message
10. Project Timeline
Week Task
1 Project planning, class structure
2 Coding of basic functions
3 Implementing game logic
4 Testing and debugging
5 Documentation and finalization
8
11. Conclusion
This project was a successful implementation of the Tic Tac
Toe game using C++. It helped demonstrate understanding of
important programming concepts such as arrays, loops,
conditions, and modularity through the use of functions. The
game runs smoothly and produces accurate outcomes for win
and draw conditions. It also enhances logical thinking and
lays a foundation for more advanced game programming.
12. Future Enhancements
Possible improvements include:
Adding a computer AI opponent (minimax algorithm)
Creating a graphical interface using SFML or SDL
Adding scoreboard tracking wins/losses
Improving input validation and error handling
Allowing players to replay without restarting the
program
_________________________________