Oop Mocroproject Final
Oop Mocroproject Final
C++
SUBMITTED BY
Project Guided by
PROF.SNEHAL PAGARE
1
MAHAVIR POLYTECHNIC, NASHIK.
CERTIFICATE
This is to certify that the Micro Project Report on “tic-tac-toe using c++ ” is
satisfactorily completed and submitted in the partial fulfillment of the requirement for
Subject "Data structure using c” in second year Computer Engineering in Semestet
third of Academic Year 2022-2023
By
Laxmi Sanas
Priyanka Mahale
Riya Kathe
Priyanka vadje
2
ACKNOWLEDGEMENT
I take this opportunity to thank all those who have contributed in successful
completion of this Micro Project work. I would like to express my sincere thanks to
my PROJECT GUIDE BY PROF.SNEHHAL PAGARE MAM who has encouraged me to
work on this project and guided me whenever required.
We also would like to express our gratitude to our H.O.D. PROF. A.D.SONAWANE
for giving us opportunities to undertake this project work at Mahavir Polytechnic,
Nashik.
We are extremely grateful to our PRINCIPAL PROF. S.V.SAGRE for his constant
inspiration and keen interest to make the project and presentation absolutely
flawless.
At the last but not the least we would like to thank our Teaching staff member,
Workshop staff member, Friends and family member for their timely co-operation
and help.
Miss.priyanka Mahale
Enrollment No. 2105300305
Miss.priyanka vadje
Enrollment No. 2205300381
S.Y.C.O.
Academic Year 2022-2023
Third Semester
3
INDEX
1 Introduction 5
2 Requirement analysis
4
INTRODUCTION
Creating a Tic Tac Toe game in C++ is easy. We can create a two-player Tic
Tac Toe game in C++ language using Array, Function, and True-False condition.Tic-
tac-toe is a game where two players X and O fill the hash (#) shaped box (consist of
two vertical lines crossing two horizontal lines) with their alternate turns. The player
who first fills the box with 3Xs or 3Os in a horizontal, vertical, or diagonal manner
will win the game. In some cases, when none of the players succeeds in filling the
boxes horizontally, vertically, or diagonally with 3Xs or 3Os, then the game will be
considered to be a draw.
Name of
S. No. Specifications Qty Remarks
Resource/material
1 Software Turboc++ 1
2 Ram 1 GB 1
3 Hard disk 32 GB 1
Hardware Requirements:-
5
I. Ram = 8GB
II. Hard Disk =32GB
III. Processor = 1.4GHz 64 bit
Software Requirements:-
I. Windows 7
● Project Planning
Action Plan :- (Sequence and time required for major activities for 8 Weeks)
Planned Name of
Planned
Sr. No. Details of activity Finish Responsible
Start date
date Team Members
Search micro project
name
Final micro project
name
Search information
about our project
Study about Micro
project Information
Coding
Testing
Power point
presentation of
micro project
Report of micro
project
Submission of report
SYSTEM IMPLEMENTATION
You probably already know how to play Tic-Tac-Toe. It's a really simple
game, right? That's what most people think. But if you really wrap your brain around
it, you'll discover that Tic-Tac-Toe isn't quite as simple as you thinkTic-Tac -Toe
6
(along with a lot of other games) involves looking ahead and trying to figure out what
the person playing against you might do next.
Program Code
#include <iostream>
using namespace std;
int checkwin();
void board();
int main()
{
int player = 1,i,choice;
char mark;
do
{
board();
player=(player%2)?1:2);
cout << "Player " << player << ", enter a number: ";
cin >> choicce;
mark=(player == 1) ? 'X' : 'O';
7
square[8] = mark;
else
{
cout<<"Invalid move ";
player--;
cin.ignore();
cin.get();
}
i=checkwin();
player++;
}while(i==-1);
board();
if(i==1)
{
cout<<"==>\aPlayer "<<--player<<" win ";
else
cout<<"==>\aGame draw";
cin.ignore();
cin.get();
return 0;
}
/*********************************************
FUNCTION TO RETURN GAME STATUS
1 FOR GAME IS OVER WITH RESULT
-1 FOR GAME IS IN PROGRESS
O GAME IS OVER AND NO RESULT
**********************************************/
int checkwin()
if (square[1] == square[2] && square[2] == square[3])
return 1;
else if (square[4] == square[5] && square[5] == square[6])
return 1;
else if (square[7] == square[8] && square[8] == square[9])
return 1;
else if (square[1] == square[4] && square[4] == square[7])
return 1;
else if (square[2] == square[5] && square[5] == square[8])
8
return 1;
else if (square[3] == square[6] && square[6] == square[9])
return 1;
else if (square[1] == square[5] && square[5] == square[9])
return 1;
else if (square[3] == square[5] && square[5]
return 1;
else if (square[1] != '1' && square[2] != '2' && square[3] != '3'
&& square[4] != '4' && square[5] != '5' && square[6] != '6'
&& square[7] != '7' && square[8] != '8' && square[9] != '9')
return 0;
else
return -1;
}
/*******************************************************************
FUNCTION TO DRAW BOARD OF TIC TAC TOE WITH PLAYERS MARK
********************************************************************/
void board()
{
system("cls");
cout << "\n\n\tTic Tac Toe\n\n";
cout << "Player 1 (X) - Player 2 (O)" << endl << endl;
cout << endl;
cout << " " << square[4] << " | " << square[5] << " | " << square[6] << endl;
9
cout << " | | " << endl;
cout << " " << square[7] << " | " << square[8] << " | " << square[9] << endl;
/*******************************************************************
END OF PROJECT
********************************************************************
OUTPUT
10
outweigh the minuses and that you learn how to develop strategies to help you pull
through. It's these kinds of life lessons that you would want to share to your children.
The game of tic-tac-toe is a game of predictability. The moves that are believed
to be important are highly predictable. This also makes it a game of opposites in a
way, because this goes against the definition of an “important move”. But this
predictability is what helps foster strategic thinking in children. They can learn
through observation what their opponents’ next move is and think ways on how to
block them, a simple but effective version of chess. In order to figure out what else
they can do in the game to win, the children are encouraged to think more logically.
They, therefore, naturally develop their logico-mathematical thinking, which can help
them in subjects such as math and engineering in the future.
CONCLUSION
We have successfully completed it. In our project we have create tic-
tac-toe game application using C++. This application very useful to children.
REFERENCES
1)www.google.com: using This website we are study of project code.
2)visit a w3school.com and search about information of project
11