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
|
#include <iostream>
using namespace std;
void the_menu(string da_blank[6], string the_guess){
cout << da_blank;
cout << "Please guess a letter: ";
cin >> the_guess;
return;
}
void guess_checker(string DA_WORD[], string da_blank[], string the_guess, int SIZE, int count_correct, int sub){
sub = 0;
while(sub < SIZE){
if(DA_WORD[sub] == the_guess){
count_correct = count_correct + 1;
da_blank[sub] = the_guess;
}
sub = sub + 1;
}
cout << da_blank << endl;
if(count_correct != SIZE){
cout << "Please guess a letter: " << endl;
cin >> the_guess;
}
return;
}
void end_game(string da_blank[6]){
cout << "You guessed the word!" << endl;
cout << da_blank;
return;
}
int main()
{
int sub = 0;
int count_correct = 0;
string the_guess;
const int SIZE = 6;
string DA_WORD[SIZE] = {"b","a","n","a","n","a"};
string da_blank[SIZE] = {"-","-","-","-","-","-"};
the_menu(da_blank, the_guess);
while(count_correct != SIZE){
guess_checker(DA_WORD, da_blank, the_guess, SIZE, count_correct, sub);
}
end_game(da_blank);
return 0;
}
| |