Documente Academic
Documente Profesional
Documente Cultură
PROJECT FILE
ON
Gaming Interface
PROJECT WORK
IN
COMPUTER SCIENCE
Gaming Interface
Prepared under the guidance of:
Name
Class
Reg No.
School
Submitted by
: SURYA A N
: XII-A
: M216 46062 0072
: C S ACADEMY, ERODE
Standard xii
COMPUTER SCIENCE
Teacher in-charge
ACKNOWLEDGEMENT
my
Computer
Science
teacher
who
CERTIFICATE
This is to certify that Mr./Ms. SURYA A N of
class XII-A has completed
his/her project
under my supervision. He/She has taken
proper care and shown utmost sincerity in
completing the project.
I certify that the project Gaming Interface is as
per CBSE Guidelines and is up to my
expectation.
TABLE OF CONTENTS
Project Synopsis
Functions
Coding
Limitations
Requirements
Bibliography
PROJECT SYNOPSIS
CLASSES AND
THEIR OBJECTS
FUNCTIONS
void getdata()-gets and assigns balanceamt as
score.
void display()-displays score.
int getscore()-get score from file.
CODING
#include<iostream.h>
#include<fstream.h>
#include<conio.h>
#include<dos.h>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
int balanceamt;
char playername[80];
class score
{
int score;
public:
void getdata()
{
score=balanceamt;
cout<<"Score\n"<<score;
}
void display()
{
cout<<score;
}
int getscore()
{
return score;
}
}s,c;
void highscr()
{
clrscr();
fstream fs;
fs.open("score.txt",ios::in|ios::out);
s.getdata();
int last=0,found=0;
while(!found&&fs.read((char*) &c, sizeof(c)))
{
if(s.getscore()>=c.getscore())
{
fs.seekg(-1* sizeof(c),ios::cur);
fs.write((char*)&s, sizeof(s));
last=1;
}
else if(last==0)
{
//fs.put(s.getscore());
fs.write((char*)&s, sizeof(s));
}
else
{
fs.put(s.getscore());
}
if(fs.eof())
{if(last==1)
found=1;
}
}
while(!fs.eof())
{
fs.read((char*)&c,sizeof(c));
c.display();
}
fs.close();
}
void draw_line(int n,char ch)
{
for(int i=0;i<n;i++)
cout<<ch;
}
void rules()
{
clrscr();
cout<<"\n\n";
draw_line(60,'-');
cout<<"\n\t\tRULES OF THE GAME\n";
draw_line(60,'-');
cout<<"\n\t0.CHEATING IS PROHIBITTED AND IF
CAUGHT DEATH PENALTY\n\t1. Choose any number
between 1 to 15\n\t2. If you win you will get 5 times
{
cout<<"\n\n"<<playername<<"\tenter money to
bet";
cin>>amt;
if(amt>balanceamt)
cout<<"Your betting amount is more than your
current balance\n\nRe-enter data\n ";
else
break;
}while(1);
do
{
cout<<"Enter your lucky number to bet between 1
to 15 :";
cin>>no;
if(no<=0||no>15)
cout<<"Please check the number!! should be
between 1 to 15\n\nRe-enter data\n ";
else
break;
}while(1);
randomize();
dice=random(15)+1;
if(dice==no)
{
cout<<"\n\nGood Luck!! You won Rs."<<amt*5;
balanceamt=balanceamt+amt*5;
}
else
{
cout<<"Bad Luck this time !! You lose Rs."<<amt;
balanceamt=balanceamt-amt;
}
cout<<"\n\nThe winning number was : "<<dice;
cout<<"\n\n\t"<<playername<<" You have Rs.
"<<balanceamt<<endl;
cout<<"\n\n-->Do you want to play (y/n)? ";
cin>>ch;
}while(ch=='Y'|| ch=='y');
clrscr();
cout<<"\n\n\n";
draw_line(70,'+');
cout<<"\n\n\t\THANKS FOR COMING TO CASINO||
YOUR
BALANCE
AMOUNT
IS
RS."<<balanceamt<<"\n\n";
draw_line(70,'+');
delay(4000);
if(balanceamt>1000)
{
cout<<"\nYou won:Rs."<<balanceamt-1000<<"\n";
}
else if(balanceamt==1000)
{
cout<<"\nNice try.You have kept your wealth safe
and but U added none to it\n";
delay(5000);
textcolor(WHITE);
clrscr();
}
else
{
cout<<"\t\nSorry,You
Wasted
your
wealth"<<"\nBy:"<<1000-balanceamt<<"\n";
delay(5000);
textcolor(WHITE);
clrscr();
}
cout<<"Highscore is"<<balanceamt;
delay(2000);
highscr();
delay(4000);
clrscr();
draw_line(70,'+');
draw_line(70,'+');
cout<<endl;
}
void play_dice(int &score)
{
int dice;
dice=random(6)+1;
cout<<"\nYou got "<<dice<<" Point !! ";
score=score+dice;
cout<<"Now you are at position "<<score;
switch(score)
{
case 98 :score=28;break;
case 95 :score=24;break;
case 92 :score=51;break;
case 83 :score=19;break;
case 73 :score=1;break;
case 69 :score=33;break;
case 64 :score=36;break;
case 59 :score=17;break;
case 55 :score=7;break;
case 52 :score=11;break;
case 48 :score=9;break;
case 46 :score=5;break;
case 44 :score=22;break;
case 8 :score=26;break;
case 21 :score=82;break;
case 43 :score=77;break;
case 50 :score=91;break;
case 54 :score=93;break;
case 62 :score=96;break;
case 66 :score=87;break;
case 80 :score=100;
}
}
void game2()
{
textcolor(YELLOW);
clrscr();
int player1=0,player2=0,lastposition;
char player1name[80],player2name[80];
clrscr();
randomize();
draw_line(50,'=');
cout<<"\n\n\n\n\t\tSNAKE LADDER GAME\n\n\n\n";
draw_line(50,'=');
cout<<"\n\n\nEnter Name of player 1 :";
gets(player1name);
cout<<"\n\n\Enter Name of player 2 :";
gets(player2name);
while(player1<=100 && player2<=100)
{
board();
gamescore(player1name,player2name,player1,playe
r2);
cout<<"\n\n--->" <<player1name<<" Now your
Turn >> Press any key to play ";
getch();
lastposition=player1;
play_dice(player1);
if(player1<lastposition)
cout<<"\n\aOops!! Snake found !! You are at postion
"<<player1<<"\n";
else if(player1>lastposition+6)
cout<<"\nGreat!! you got a ladder !! You are at
position "<<player1;
cout<<"\n\n--->"<<player2name<<" Now your Turn
>> Press any key to play ";
getch();
lastposition=player2;
play_dice(player2);
if(player2<lastposition)
cout<<"\n\n\aOops!! Snake found !! You are at
position "<<player2<<"\n";
else if(player2>lastposition+6)
if (guess == guessword[i])
return 0;
if (guess == secretword[i])
{
guessword[i] = guess;
matches++;
}
}
return matches;
}
void initUnknown (char word[], char unknown[])
{
int i;
int length = strlen(word);
for (i = 0; i < length; i++)
unknown[i]='*';
unknown[i]='\0';
}
void game3()
{
textcolor(GREEN);
clrscr();
char unknown [MAXLENGTH];
char letter;
int num_of_wrong_guesses=0;
char word[MAXLENGTH];
char words[][MAXLENGTH] =
{
"india",
"pakistan",
"nepal",
"malaysia",
"philippines",
"australia",
"iran",
"ethiopia",
"oman",
"indonesia",
"armenia",
"vietnam",
"japan",
"iraq",
"isreal",
"canada",
"chile",
"peru",
"uruguay",
"argentina",
"nigeria",
"brazil",
"spain",
"italy",
"russia",
"austria",
"uzbekistan",
"afganistan",
"egypt",
"colombia",
"turkey",
"finland",
"switzerland",
"maldives",
"neatherland",
"portugal",
"france",
"bhutan",
"china",
"northkorea",
"southkorea",
"sudan",
"greece",
"mangolia",
"paraguay",
"germany",
"hungary",
"southafrica",
"uganda",
"morocco"
};
randomize();
int n=random(50);
strcpy(word,words[n]);
initUnknown(word, unknown);
cout << "\n\nWelcome to hangman...Guess a
country Name";
cout << "\n\nEach letter is represented by a star.";
cout << "\n\nYou have to type only one letter in one
try";
cout << "\n\nYou have " << MAX_TRIES << " tries to
try and guess the word.";
cout
<<
"\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~";
while (num_of_wrong_guesses < MAX_TRIES)
{
cout << "\n\n" << unknown;
cout << "\n\nGuess a letter: ";
cin >> letter;
if (letterFill(letter, word, unknown)==0)
{
cout << endl << "Whoops! That letter isn't in
there!" << endl;
num_of_wrong_guesses++;
}
else
{
cout << endl << "You found a letter! Isn't that
exciting!" << endl;
}
cout << "You have " << MAX_TRIES num_of_wrong_guesses;
textcolor(RED);
clrscr();
cout<<"Your PC is under the Surveillance of JPP
virus\n\n\n\n";
cout<<"New Volume I::Deleted\n";
delay(5000);
cout<<"New Volume H::Deleted\n";
delay(1500);
cout<<"New Volume G::Discarded\n";
delay(2000);
cout<<"New Volume E::Deleted\n";
delay(2500);
cout<<"New Volume D::Deleted\n";
delay(2000);
cout<<"New Volume C::Cleaned\n";
delay(4000);
textcolor(RED);
clrscr();
cout<<"\n\n\n\n\t\t\tYour pc is Affected intensely by
an Unknown virus\n\n";
cout<<"\n\n\n\n\t\t\tHappy Valentine's day";
delay(10000);
textcolor(YELLOW+BLINK);
clrscr();
do
{delay(10);
cout<<"-_-";
delay(50);
cout<<".";
delay(50);
if(i==999)
{
delay(1000);
textcolor(RED+BLINK);
clrscr();
cout<<"SyStEm CrAsHeD";
delay(10000);
clrscr();
rip:
if(t>0)
{
textcolor(GREEN);
clrscr();
cout<<"SyStEm
ReBoOt
initiated
in
"<<"\t\t00:"<<t;
delay(1000);
t--;
clrscr();
goto rip;
}
delay(3000);
textcolor(BLUE);
clrscr();
}
i++;
}while(i!=1000);
}
void confirmation()
{
int k=0;
char f;
delay(1000);
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\tWelcome
to GAMING CLUB\n\t\t\t[RESTRICTED ENTRY ONLY]";
delay(5000);
cout<<"\n\n\t\t\t\t\tEnter KEY";
delay(2000);
cout<<"\n\t\t\t\t\tHERE-->";
cin>>f;
delay(3000);
clrscr();
delay(4000);
cout<<"Your key is being processed\n";
do
{delay(1000);
cout<<"::";
delay(2000);
k++;
}while(k!=8);
clrscr();
if(f=='C'||f=='c')
{
cout<<"Valid key";
delay(3000);
clrscr();
game1();
}
else if(f=='S'||f=='s')
{
cout<<"Valid key";
delay(3000);
clrscr();
game2();
}
else if(f=='H'||f=='h')
{
cout<<"Valid key";
delay(3000);
clrscr();
game3();
}
else
{
textcolor(RED+BLINK);
clrscr();
cout<<"INVALID KEY";
delay(9000);
clrscr();
cout<<"\nILLEGAL ENTRY ATTEMPT DETECTED\n";
cout<<"\n\tFail Safe Mechanism initiated----ENTRY
KILLING VIRUS INTRODUCED";
delay(10000);
clrscr();
ffool();
cout<<"VIRUS
EXPELLED"<<"\nILLEGAL
ENTRY&CHEATING ATTEMPT AVERTED\n\n";
cout<<"Remember dude wrong key means illegal
entry here so beware\n";
delay(10000);
textcolor(WHITE);
clrscr();
confirmation();
}
}
void main()
{int a;
char b;
textcolor(CYAN);
clrscr();
wip:
cout<<"\n\nWARNING:This VENTURE is a mandatory
full go through \n\tso no turning back in the middle";
cout<<"\n[-_-]Do you want to go in (just for a
confirmation)(y/n):";
cin>>b;
if(b=='y'||b=='Y')
{}
else if(b=='n'||b=='N')
{
exit(0);
}
else
{
clrscr();
cout<<"InVALID ENTRY"<<"\nPRESS Y OR N";
goto wip;
}
textcolor(WHITE);
clrscr();
confirmation();
cout<<"\n\n\nAPROJECT
DONE
BY
ANS"<<"\n\n\n\n\n\n\t\t\t\n\n\n\n\n\n\n\n\n\n\n\n\n\n\
n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t\t\t\
t(c)SURYA bros";
delay(10000);
textcolor(WHITE);
clrscr();
sip:
cout<<"Do you want to continue in the club(press 1)
or exit(press 0)";
cin>>a;
if(a==1)
{
clrscr();
confirmation();
}
else if(a==0)
{textcolor(BLUE+BLINK);
cout<<"Hope you enjoyed"<<"\nTHNX BUDDY!!";
delay(5000);
}
else
{
cout<<"\nInvalid Entry"<<"\npress 1 or 0 only";
delay(2000);
goto sip;
}
getch();
}
OUTPUTS
LIMITATIONS
BEEN ADDED.
REQUIREMENTS
HARDWARE
REQUIRED
Printer, to print the required documents of
the project
Compact Drive
Processor : Pentium III
Ram : 64 MB
Harddisk : 20 Gb.
SOFTWARE REQUIRED
Operating system : Windows XP
Turbo C++, for execution of program and
Ms word, for presentation of output.
BIBLIOGRAPHY