You are on page 1of 10

#include<iostream.

h>

#include<process.h>

#include<conio.h>

#include<stdlib.h>

int j;

void instructions()

{ gotoxy(30,7);

char t;

cout<<”INSTRUCTIONS..”;

cout<<”\n”<<”1 : This game tests your thinking ability…”;

cout<<”\n”<<”2 : The theme of this game is to explore the word in the computer’s mind..”;

cout<<”\n”<<”3 : You will be given four chances to explore it …”;

cout<<”\n”<<”4 : Clues will be provided for every chance…”;

cout<<”\n”<<5 : After each chance the no.of Accurate and Precise letters in the submitted”;
cout<<”\n”<<” word will be displayed..”;

cout<<”\n”<<6 : Both accurate and precise letters will be present in the computer’s word..”;

cout<<”\n”<<”7 : ACCURATE LETTERS : Those whose position is the same as that in the word..”;

cout<<”\n”<<”8 : PRECISE LETTERS: Those whose position is not the same as that in the word.”;

gotoxy(30,22);

cout<<”!!CLUES!!”;

cout<<”\n”<<”CLUE 1 : Produces a letter in the computer’s word…”;

cout<<”\n”<<”CLUE 2: Produces the range of the first letter…”;

cout<<”\n”<<”CLUE 3: Produces the range of the second letter..”;

cout<<”\n”<<”CLUE 4: Produces the range of the third letter..”;

cout<<”\n”<<”CLUE 5 :Produces the range of the fourth letter,,”;

}
class game

{ char a[4] , p[4] , q[4] , r[4] , s[4];

int e,f,g,h;

public:

void minigame();

void checkp(), checkq(), checkr(), checks();

void clue1(), clue2(), clue3(), clue4(), clue5();

);

void main()

game z[11];

for(int i=0;i<=10;i++)

{clrscr();

j=0;

char ch;

gotoxy(20,3);

cout<<”WELCOME TO THE GAME OF ‘GUESS THE WORD..’”;

cout<<”\n”<<”Press Y to continue..”<<”\n”<<”Press N to quit..”;

gotoxy(0,7);

instructions();

cin>>ch;

switch(ch)

{ case ‘Y’ : clrscr();z[i].minigame();break;


case ‘y’ : clrscr();z[i].minigame();break;

case ‘n’ : exit(0);break;

case ‘N’ : exit(0);break;

default : cout <<”Sorry, Wrong option..”;exit(0);break;}

getch();

}}

void game::minigame()

{ int u,v,w,x;

srand(time(0));

e= (97+rand()%25);

f= (97+rand()%25);

if(e==f)

{for(int i=0;e==f;i++)

{f= (97+rand()%25);}}

g= (97+rand()%25);

if (g==f||g==e)

{for(i=0;g==f||g==e;i++)

{g= (97+rand()%25);}}

h= (97+rand()%25);

if(h==e||h==f||h==g)

{for(i=0;h==e||h==f||h==g;i++)

{h= (97+rand()%25);}}

a[0]= char(e); a[1]= char(f); a[2]= char(g); a[3]= char(h);

cout<<”\n”<<”ENTER THE FIRST SET OF FOUR LETTERS..”;


for(int k=0;k<4;k++)

{cin>>p[k];}

checkp();

cout<<”\n”<<” Enter the clue no.”;

cin>> u;

switch(u)

{ case 1: clue1();break;

case 2: clue2();break;

case 3: clue3();break;

case 4: clue4();break;

case 5: clue5();break;

default: cout<<”\n”<<”Oops!..Sorry you have pressed the wrong key!”;

cout<<”\n”<<”No Clues will be given..”; break; }

cout<<”\n”<<”\n”<<”ENTER THE SECOND SET OF FOUR LETTERS..”;

for(k=0;k<4;k++)

{cin>>q[k];}

checkq();

cout<<”\n”<<” Enter the clue no.”;

cin>>v;

switch(v)

{ case 1: clue1();break;

case 2: clue2();break;

case 3: clue3();break;

case 4: clue4();break;

case 5: clue5();break;
default: cout<<”\n”<<”Oops!..Sorry you have pressed the wrong key!”;

cout<<”\n”<<”No Clues will be given..”; break; }

cout<<”\n”<<”ENTER THE THIRD SET OF FOUR LETTERS..”;

for(int k=0;k<4;k++)

{cin>>r[k];}

checkr();

cout<<”\n”<<” Enter the clue no.”;

cin>> w;

switch(w)

{ case 1: clue1();break;

case 2: clue2();break;

case 3: clue3();break;

case 4: clue4();break;

case 5: clue5();break;

default: cout<<”\n”<<”Oops!..Sorry you have pressed the wrong key!”;

cout<<”\n”<<”No Clues will be given..”; break; }

cout<<”\n”<<”ENTER THE FOURTH SET OF FOUR LETTERS..”;

for(int k=0;k<4;k++)

{cin>>s[k];}

checks();

cout<<”\n”<<”\n”<<”The word is “;

for(int y=0;y<4;y++)

{cout<<a[y];}}

void game::checkp()
{ int em=0;

int tr=0;

for(int i=0;i<4;i++)

{ for(int j=o;j<4;j++)

{if(a[i]==p[j] && i==j)

em++;

else if(a[i]==p[j] && i!=j)

tr++; }}

if(em==4)

cout<<”\n”<<”!!!YOU WON!!!”<<”\n”<<”The word is “;

for(i=0;i<4;i++)

{cout<<p[i];}

j=1;}

else

{cout<<”\n”<<”No.of Accurate letters is “<<em;

cout<<”\n”<<”No.of Precise letters is “<<tr<<”\n”; }}

void game::checkq()

{ int em=0;

int tr=0;

for(int i=0;i<4;i++)

{ for(int j=o;j<4;j++)

{if(a[i]==q[j] && i==j)

em++;

else if(a[i]==q[j] && i!=j)


tr++; }}

if(em==4)

cout<<”\n”<<”!!!YOU WON!!!”<<”\n”<<”The word is “;

for(i=0;i<4;i++)

{cout<<q[i];}

j=1;}

else

{cout<<”\n”<<”No.of Accurate letters is “<<em;

cout<<”\n”<<”No.of Precise letters is “<<tr<<”\n”; }}

void game::checkr()

{ int em=0;

int tr=0;

for(int i=0;i<4;i++)

{ for(int j=o;j<4;j++)

{if(a[i]==r[j] && i==j)

em++;

else if(a[i]==r[j] && i!=j)

tr++; }}

if(em==4)

cout<<”\n”<<”!!!YOU WON!!!”<<”\n”<<”The word is “;

for(i=0;i<4;i++)

{cout<<r[i];}

j=1;}

else

{cout<<”\n”<<”No.of Accurate letters is “<<em;


cout<<”\n”<<”No.of Precise letters is “<<tr<<”\n”; }}

void game::checks()

{ int em=0;

int tr=0;

for(int i=0;i<4;i++)

{ for(int j=o;j<4;j++)

{if(a[i]==s[j] && i==j)

em++;

else if(a[i]==s[j] && i!=j)

tr++; }}

if(em==4)

cout<<”\n”<<”!!!YOU WON!!!”<<”\n”<<”The word is “;

for(i=0;i<4;i++)

{cout<<s[i];}

j=1;}

else

{cout<<”\n”<<”No.of Accurate letters is “<<em;

cout<<”\n”<<”No.of Precise letters is “<<tr<<”\n”; }}

void game::clue1()

{int u=1+rand()%3;

cout<<”\n”<<a[u];}

void game::clue2()

{ if(int(a[0])>=100 && int(a[0]<=119)


{ cout<<char(int(a[0])-3)<<”-“<<”char(int(a[0])+3;}

else if (int(a[0])<100 && int(a[0])>96)

{ cout<<”a- “<<char(int(a[0])+3);}

else { cout<<char(int(a[0])-3<<” - z”;}}

void game::clue3()

{ if(int(a[1])>=100 && int(a[1]<=119)

{ cout<<char(int(a[1])-3)<<”-“<<”char(int(a[1])+3;}

else if (int(a[1])<100 && int(a[1])>96)

{ cout<<”a- “<<char(int(a[1])+3);}

else { cout<<char(int(a[1])-3<<” - z”;}}

void game::clue4()

{ if(int(a[2])>=100 && int(a[2]<=119)

{ cout<<char(int(a[2])-3)<<”-“<<”char(int(a[2])+3;}

else if (int(a[2])<100 && int(a[2])>96)

{ cout<<”a- “<<char(int(a[2])+3);}

else { cout<<char(int(a[2])-3<<” - z”;}}

void game::clue5()

{ if(int(a[3])>=100 && int(a[3]<=119)

{ cout<<char(int(a[3])-3)<<”-“<<”char(int(a[3])+3;}

else if (int(a[3])<100 && int(a[3])>96)

{ cout<<”a- “<<char(int(a[3])+3);}

else { cout<<char(int(a[3])-3<<” - z”;}}

You might also like