Added error method for non-alphabetic characters

For anyone that is interested, when I entered \0 as a test, I kept getting the ‘not lowercase’ error message, so I added Not_Alpha to the enum class, with appropriate message in the switch statement to handle non-alphabetic characters and added this helper method declaration in the header file:

bool IsLetter(FString) const;

and this definition for it in FBullCowGame.Cpp

bool FBullCowGame::IsLetter(FString Word) const
{
for (auto Letter : Word)
{
if (! isalpha(Letter))
{
return false;
}
}
return true;
}

If you decide to use it, make it the first if statement at the top of CheckGuessValidity like this:

if (!IsLetter(Guess))// check for only alphabetic characters FIRST
{
return EGuessWordStatus::Not_Alpha;
}

isalpha() will only return true if it is alphabetic.

Cheers!

Privacy & Terms