Anda di halaman 1dari 26

GAME

PROJECT REPORT ON
GAME:

SUBMITTED BY
MISS ADITI SHUKLA

PROJECT GUIDE
MRS.MANJIRI K. GUJAR

SCHOOL
NEW HORIZON SCHOLARS SCHOOL.AIROLI
11th COMPUTER SCIENCE
AISSCE 2017
CBSE

1
GAME

COMPUTER SCIENCE PROJECT

GAME

2
GAME

#1

PREFACE

3
GAME

In order to gain practical


knowledge in the field of
program development, we are
required to make a project on
“Game: Tic Tac Toe”. The basic
objective behind doing this
project is to get acquainted with
the c++ language.

In this project report we have


used concept of array.

4
GAME

Doing this project report helped


us enable our knowledge
regarding Object Oriented
Programming. Through this
project we come to know about
the importance of team work
and role of devotion towards
work. Also it has helped us to
develop our mind to work
technically.

5
GAME

#2
ACKNOWLEDGEMENT

6
GAME

The essential requirements for


the creation of any project are
able guides and references.
Without them ,a project is
forever incomplete.
I would like to express my
sincere thanks to my teacher
Mrs.Manjiri K.Gujar ,as well as
to our principal,Mrs Tanuja
Bhatt,who helped me in my
research work and gaining

7
GAME

knowledge in the arena of c++


language.
Secondly,I would also like to
thank my parents,my tutor and
my group members, who
assisted me day in and day out
,and because of whom I have
been able to accomplish this
task within limited period of
time.
I would also like to thank CBSE
for giving me thus golden

8
GAME

opportunity to undertake this


project.
Last but not the least; I’d like to
thank all my colleagues, friends
and other persons who have
directly or indirectly helped me
during the preparation of this
report.

Thank you.

9
GAME

#3
coding

10
GAME

11
GAME

#include <iostream.h>
#include <conio.h>

char square[10] = {'o','1','2','3','4','5','6','7','8','9'};


int checkwin();
void board();

int main()
{
int player = 1,i,choice;
char mark;
clrscr();
do
{
board();
player=(player%2)?1:2;
cout << "Player " << player << ", enter a number:
";

12
GAME

cin >> choice;


mark=(player == 1) ? 'X' : 'O';
if (choice == 1 && square[1] == '1')
square[1] = mark;
else if (choice == 2 && square[2] == '2')
square[2] = mark;
else if (choice == 3 && square[3] == '3')
square[3] = mark;
else if (choice == 4 && square[4] == '4')
square[4] = mark;
else if (choice == 5 && square[5] == '5')
square[5] = mark;
else if (choice == 6 && square[6] == '6')
square[6] = mark;
else if (choice == 7 && square[7] == '7')
square[7] = mark;
else if (choice == 8 && square[8] == '8')
square[8] = mark;
else if (choice == 9 && square[9] == '9')
13
GAME

square[9] = mark;
else
{
cout<<"Invalid move ";
player--;
getch();
}
i=checkwin();
player++;
}while(i==-1);
board();
if(i==1)
cout<<"==>\aPlayer "<<--player<<" win ";
else
cout<<"==>\aGame draw";
getch();
return 0;
}
/*********************************************
14
GAME

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;

15
GAME

else if (square[2] == square[5] && square[5] ==


square[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] ==
square[7])
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

16
GAME

return -1;
}

/***********************************************
********************
FUNCTION TO DRAW BOARD OF TIC TAC TOE WITH
PLAYERS MARK
************************************************
********************/

void board()
{
clrscr();
cout << "\n\n\tTic Tac Toe\n\n";
cout << "Player 1 (X) - Player 2 (O)" << endl << endl;
cout << endl;
cout << " | | " << endl;

17
GAME

cout << " " << square[1] << " | " << square[2] << " |
" << square[3] << endl;
cout << "_____|_____|_____" << endl;
cout << " | | " << endl;
cout << " " << square[4] << " | " << square[5] << " |
" << square[6] << endl;
cout << "_____|_____|_____" << endl;
cout << " | | " << endl;
cout << " " << square[7] << " | " << square[8] << " |
" << square[9] << endl;
cout << " | | " << endl << endl;
}

/***********************************************
********************
END OF PROJECT
************************************************
********************/

18
GAME

#4
Output

19
GAME
When one player win the game:

1)

2)

20
GAME
3)

4)

21
GAME
5)

22
GAME

23
GAME

24
GAME

25
GAME

26

Anda mungkin juga menyukai