Cant see duplicate out

Can someone please tell me why I get a duplicate ask for, Do you want to Play Again. Im sure its staring me in the face but I just dont see it.
//PreDirectives
#include
#include

using namespace std;

void Printintro();
void PlayGame();
string GetGuess();
bool AskToPlayAgain();

// The entry point for our application
int main()
{
bool bPlayAgain = false;
do
{
Printintro();
PlayGame();
AskToPlayAgain();
bPlayAgain = AskToPlayAgain();
} while (bPlayAgain);
return 0;// exit the application

}

void Printintro()

{
// Introduce The Game Bulls And Cows
constexpr int WORD_LENGTH = 5;
cout << “Welcome to Bulls and Cows a Fallout game\n”;
cout << "Can you guess the " << WORD_LENGTH;
cout << " letter isogram?\n\n ";
cout << endl;
return;
}

void PlayGame()

{
// Loop for the number of turns asking for guess
constexpr int NUMBER_OF_TURNS = 5;
for (int count = 1; count <= NUMBER_OF_TURNS; count++)
{
string Guess = GetGuess ();
// print the guess back
cout << " your guess was: " << Guess << endl;
cout << endl;
}
}

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

bool AskToPlayAgain()
{
cout << “Do You Want To Play Again(y/n)?”;
string Response = “”;
getline(cin, Response);
return (Response[0] == ‘y’) || (Response[0] == ‘Y’);
}

in main you have:

AskToPlayAgain();
bPlayAgain = AskToPlayAgain();
1 Like

Thank you Dan Again, your the man…

Privacy & Terms