So I followed the lesson pretty closely, the code runs fine and it plays again to Yes or yes and quits for any other non y word. I’ve run into a slight problem Whenever I play again it skips the first turn like so.
The weird thing is it runs through fine on the first run every time It allows me to guess all five times.
Any help or tips appreciated My code is below:
#include
#include
using namespace std;
//Function Calling
void Intro();
void PlayGame ();
string GetGuess ();
string ReturnGuess();
bool PlayAgain();
//Main Function
//Intro and PlayGame stored
int main()
{
//Game
Intro();
do
{
PlayGame();
}
while (PlayAgain() == true);
return 0;
}
// introduce the Game
void Intro ()
{
//variables
constexpr int Word = 5;
cout << "Welcome to the Bull Cow Game! \n" << endl;
cout << "Can you guess the " << Word << " letter isogram?\n";
return;
}
// Game rules and run through
// ReturnGuess stored
void PlayGame ()
{
//Variables
int Turns = 5;
for (int a = 1; a <= Turns; a++)
{
ReturnGuess();
}
return;
}
//Get player guess
string GetGuess ()
{
//variables
string Guess;
// Get Guess
cout <<"Enter your guess: ";
getline(cin,Guess);
return Guess;
}
// Return Guess
//GetGuess stored
string ReturnGuess ()
{
string Guess = GetGuess();
cout << Guess << endl;
return Guess;
}
//Asking to play the game again
bool PlayAgain()
{
string Response;
cout << “Would you like to play again? (Y/N)\n”;
cin >> Response;
return (Response[0] == 'y') || (Response[0] == 'Y');
}