My apologies, I would forget the most important part.
Main.cpp:
#include
#include
#include “FBullCowGame.h”
using FText = std::string;
using int32 = int;
void PrintIntro();
void PlayGame();
FText GetValidGuess();
bool AskToPlayAgain();
FBullCowGame BCGame;
int main()
{
bool bPlayAgain = false;
do {
PrintIntro();
PlayGame();
bPlayAgain = AskToPlayAgain();
}
while (bPlayAgain);
return 0;
}
void PrintIntro()
{
std::cout << “\n\nWelcome to Bulls and Cows, a fun word game.\n”;
std::cout << “Can you guess the " << BCGame.GetHiddenWordLength();
std::cout << " letter isogram I’m thinking of?\n”;
std::cout << std::endl;
return;
}
void PlayGame()
{
BCGame.Reset();
int32 MaxTries = BCGame.GetMaxTries();
while (!BCGame.IsGameWon() && BCGame.GetCurrentTry() <= MaxTries) {
FText Guess = GetValidGuess();
FBullCowCount BullCowCount = BCGame.SubmitValidGuess(Guess);
std::cout << "Bulls = " << BullCowCount.Bulls;
std::cout << ". Cows = " << BullCowCount.Cows << "\n\n";
}
}
FText GetValidGuess()
{
EGuessStatus Status = EGuessStatus::Invalid_Status;
FText Guess = “”;
do {
int32 CurrentTry = BCGame.GetCurrentTry();
std::cout << "Try " << CurrentTry << ". Enter your guess: ";
std::getline(std::cin, Guess);
Status = BCGame.CheckGuessValidity(Guess);
switch (Status)
{
case EGuessStatus::Wrong_Length:
std::cout << "Please enter a " << BCGame.GetHiddenWordLength() << " letter word.\n";
break;
case EGuessStatus::Not_Isogram:
std::cout << "Please enter a word without repeating letters.\n";
break;
case EGuessStatus::Not_Lowercase:
std::cout << "Please enter all lowercase letters.\n";
break;
default:
// Assume Guess is valid
break;
}
std::cout << std::endl;
} while (Status != EGuessStatus::OK);
return Guess;
}
bool AskToPlayAgain()
{
std::cout << "Do you want to play again (y/n)? ";
FText Response = “”;
std::getline(std::cin, Response);
return (Response[0] == ‘y’) || (Response[0] == ‘Y’);
}