My code works fine, and I get the correct error message about word length in my program, but the error that is supposed to present itself in the “Error List” (‘GetValidGuess’: not all control paths return a value) does not appear. My code is exactly the same as Ben’s, and works as expected. Could it just be a newer version of Visual studio that recognizes that the code is safe? I guess this is a good “problem” to have, but I want to make sure my code is correct.
Here is my code in case you doubt me:
FText GetValidGuess()
{
EGuessStatus Status = EGuessStatus::Invalid_Status;
do {
// get a guess from the player
int32 CurrentTry = BCGame.GetCurrentTry();
std::cout << "Try " << CurrentTry << ". Enter your guess: ";
FText 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 an Isogram(Word without repeating letters)!\n";
break;
case EGuessStatus::Not_Lowercase:
std::cout << "Please enter your guess in lowercase!\n";
break;
default:
return Guess;
}
return Guess;
} while (Status != EGuessStatus::Ok);//keep looping until no errors present
}