I’m just putting this out there in case somebody would like to see alternatives to the do-while loop (I had initially done this with a dummy bool that changed when it reached “OK” status). Please let me know if you have any questions or comments (especially if you think this is a bad idea)! I already tested it out and it works.
Ftext GetValidGuess()
{
Ftext UserGuess = “”;
std::cout << "\nTry " << BCGame.GetCurrentTry() << ". ";
std::cout << "Please enter your guess: ";
getline(std::cin, UserGuess);
EWordStatus Status;
Status = BCGame.CheckGuessValidity(UserGuess);
switch (Status)
{
case EWordStatus::Wrong_Length:
std::cout << “Please enter a " << BCGame.GetHiddenWordLength() << " letter word.\n”;
return GetValidGuess();
break;
case EWordStatus::Not_Isogram:
std::cout << “Please enter an isogram. An isogram is a word where no letters repeat.\n”;
return GetValidGuess();
break;
case EWordStatus::Not_Lowercase:
std::cout << “Your word needs to be in all lowercase!\n”;
return GetValidGuess();
break;
default:
return UserGuess;
break;
}
}