#include
#include
using namespace std;
void PrintIntro();
void PlayGame();
string GetGuess();
bool AskToPlayAgain();
// get a guess from the player
string GetGuessAndReturnInput();
// the entry point for our application
int main()
{
string locresponse = “”;
PrintIntro();
PlayGame();
AskToPlayAgain();
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;
}
}
bool AskToPlayAgain()
{
cout << "Do you want to play again? ";
string Response = “”;
getline(cin, Response);
cout << "is it y? ";
int ybool;
ybool=((Response[0] == 'y') || (Response[0] == 'Y'));
if (ybool == 1)
{
main();
return true;
}
else
{
return false;
}
}