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
|
#include <iostream>
#include <string>
using namespace std;
const int maxIndex = 100;
typedef int IntArrayType[maxIndex];
string gameSearch(char&, int, string&);
void getInitWord(string&, int&, string&);
void guessWord(char&, string&, int);
void solution(string&);
int main ()
{
string word;
string finalGuess;
int tries;
char guess;
string solution = "";
getInitWord(word, tries, solution);
finalGuess = word;
while(tries != 0)
{
guessWord(guess, word, tries);
cout << solution;
gameSearch(guess, tries, word);
}
}
void getInitWord(string& w, int& numOfTries, string& solution)
{
cout << "Enter the word to be guessed: ";
cin >> w;
cout << "Enter the max number of tries: ";
cin >> numOfTries;
string star = "*";
int solSize = w.size();
for(int i=0; i < solSize; i++)
{
solution = solution + star;
}
}
string gameSearch(char& guess, int Count, string& Target)
{
return 0;
}
void guessWord(char& letter, string& word, int tries)
{
cout << "Guess a letter (You have " << tries << " left): ";
cin >> letter;
}
|