1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
#include<iostream>
#include <ctime>
#include <cstdlib>
#include <string>
using namespace std;
int select;
int category;
static int wordchoice;
string line[];
string words_sport[11]={"LionelMessi","CristianoRonaldo","Pep","Drogba","Soccer","DavidVilla","Pique","Nemar","Cruyff","Mohammad","Mohamad"};
string movies[5]={"IronManThree","BatMan","SpiderMan","Avengers","GhostBusters"};
string brands[9]={"Nike","Sony","Microsoft","Toshiba","LG","Apple","Nokia","Nintendo","Sega"};
void lines(string a[],string line[]){
int counter=a[wordchoice].length();
for(int i=0;i<counter;i++){
//cout<<"_ ";
line[i]='_';
}
for(int i=0;i<counter;i++){
cout<<line[i]<<" ";
}
}
int main(){
cout<<"*************************Welcome to the Hang Man Game!*************************"<<endl;
cout<<" Type 1 to start "<<endl;
cin>>select;
while(select!=1){
cout<<"Type 1 to start";
cin>>select;
}
system("CLS");
cout<<"Please chose a category: 1-Sports, 2-Movies, 3-Brand Names"<<endl;
cin>>category;
while(category!=1 && category !=2 && category != 3){
cout<<"Please chose a category: 1-Sports, 2-Movies, 3-Brand Names"<<endl;
cin>>category;
}
system("CLS");
switch(category){
case 1:
cout<<"Sports selected, please guess the word you have 10 chances."<<endl;
wordchoice=rand()%10+0;
lines(words_sport,line);
break;
case 2:
cout<<"Movies selected, please guess the word you have 10 chances."<<endl;
wordchoice=rand()%4+0;
lines(movies,line);
break;
case 3:
cout<<"Brands selected, please guess the word you have 10 chances."<<endl;
wordchoice=rand()%8+0;
lines(brands,line);
break;
}
}
|