Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 8

Cambridge School Indirapuram

Computer Game File


By Aryan Jaiswal
Roll no:3
Certificate

Name _______________________ Class ____________


Roll no _______ Exam Type _______________________
Institution ______________________________________

We certificate this to be the meritorious work of the


student in the _________________ practical during the
academic year 2018-2019.

Number of practicals certified ________ out of_________


In the subject of _________________________________

____________ ___________ ___________


Examiner’s Subject teacher’s Principal’s
Signature Signature Signature

Date ____________
PROLOGUE
This project is based on a game 0’s and X’s or Tic-tac-toe
(American English), noughts and crosses (British English)
or Xs and Os, is a paper-and-pencil game for two players,
X and O, who take turns marking the spaces in a 3×3 grid.
The player who succeeds in placing three of their marks
in a horizontal, vertical, or diagonal row wins the game.

An early variation of tic-tac-toe was played in the Roman


Empire, around the first century BC. It was called terni
lapilli (three pebbles at a time) and instead of having any
number of pieces, each player only had three, thus they
had to move them around to empty spaces to keep
playing. The game's grid markings have been found
chalked all over Rome. Another closely related ancient
game is Three Men's Morris which is also played on a
simple grid and requires three pieces in a row to finish,
and Picaria, a game of the Puebloans.
Code for the game
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
int main()
{
clrscr();
randomize();
int choice;
int i;
char res;
int comp=random(3)+1;
int a=1;
cout << "Rock/Paper/scissors is a simple game.The rule is simple and are as follow
-: \n Rock beats scissors. \n Scissors beats Paper. \n Paper beats rock.\n";
cout << "Game Choices.\n\n";
cout << "1. Rock\n";
cout << "2. Paper\n";
cout << "3. Scissors\n";
cout << "4. Quit, exits the game.\n\n";
while(a==1)
{
cout<<"Please enter your choice.";
cin>>choice;
if (choice == 1) //Rock
{
cout << "You picked Rock.";
}

else if (choice == 2) //Paper


{
cout << "You picked Paper.";
}

else if (choice == 3) //Scissors


{
cout << "You picked Scissors.";
}
else if ( choice == 4)
{
return 0;
}
cout<<"\n Computer chooses ";

if (comp==1) //Computer rock


{
res = 1;
cout << "Rock!\n";
}

else if (comp==2) //Computer paper


{
res = 2;
cout << "Paper!\n";
}
else if (comp==3) // Computer scissors
{
res = 3;
cout << "Scissors!\n";
}
if(choice==1)
{
if(res==1)
cout<<"\n Ohh , Tie !!! ";
if(res==2)
cout<<"\n Computer wins !!!";
if(res==3)
cout<<"\n Congrats , You won !!!";
}
if(choice==2)
{
if(res==1)
cout<<"\n Congrats , You won !!!";
if(res==2)
cout<<"\n OHH , Tie !!!";
if(res==3)
cout<<"\n Sorry , you lose";
}
if(choice==3)
{
if(res==1)
cout<<"\n Sorry , You lose !!";
if(res==2)
cout<<"\n Congrats , Yoy won !!";
if(res==3)
cout<<"\n Ohh , Tie !!!";
}
cout<<"\n Enter 1 for continue or enter 0 for exit.";
cin>>a;
cout<<endl;
cout<<endl;
}
getch();
}
Output screen

You might also like