Clarity is worth fighting for challenge

Hello all,

I did it this way:

#include
#include

using namespace std;

void PrintIntro();
void PlayGame();
string GetGuess();
string PrintBack();

// the entry point for our application
int main()
{
PrintIntro();
PlayGame();
return 0; //exit application
}

//loop for the number of turns asking for guesses
void PlayGame()
{
constexpr int limit = 5;
for (int count = 1; count <= limit; count++)
{
GetGuess();
cout << endl;
PrintBack();
cout << endl;
}
}

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

// get a guess from the player
string GetGuess()
{
cout << "Enter your guess: ";
string Guess = “”;
getline(cin, Guess);
}

// print the guess back
string PrintBack()
{
string Guess = “”;
cout << "Your guess was: " << Guess << endl;
return Guess;

}

I suspect you will find that your PrintBack() prints nothing.

1 Like

Privacy & Terms