My Guess Code

For the record I did my spacing before watching the solution after the challenge was made… I know it looks fishy.

#include
#include

using namespace std;

void PrintIntro();
void PlayGame();
string GetGuess();
// get a guess from the player
string GetGuessAndReturnInput();

// the entry point for our application
int main()
{
string locresponse = “”;
PrintIntro();
PlayGame();
cout << endl;
return 0;
}

void PlayGame()
{
// loop for the number of guesses
constexpr int CLIMIT = 5;
for (int ccount = 1; ccount <= CLIMIT; ccount++)
{
cout << GetGuessAndReturnInput();
}
}

// introduce the game
void PrintIntro() {
cout << “Welcome to Bulls and Cows a fun word game.\n”;
constexpr int WORD_LENGTH = 5;
cout << "Can you guess the “;
cout << WORD_LENGTH;
cout << " letter isogram I’m thinking of ?\n”;
cout << endl;
return;
}

// get a guess from the player
string GetGuessAndReturnInput() {
string RespPt1 = “”;
cout << “Please enter your guess:\n”;

return GetGuess();

}

string GetGuess()
{
string Guess = “”;
string Response = “”;
getline(cin, Guess);

if ((Guess != "") && (Guess != " ")) {
	Response = "\nYou have guessed: " + Guess + "!\n\n";
	return Response;
}

}

Privacy & Terms