Lecture 44 IsLowerCase()

bool FBullCowGame::IsLowerCase(FString Word) const
{
    for (auto Letter : Word) {
        if (Letter < 'a' || Letter > 'z') { return false; }
    }
    return true;
}
1 Like

Nice and clean Stephen

  • My IsLowercase() helper method

  • My IsEmpty() helper method to handle zero length, \0 and spaces
  • Instead of Word == “” --> Word.length == 0 should be possible, too.
  • I don’t know if it would be enough to read the first space, but I search for at least one char in the word.

My CheckGuessValidi() method

  • I added in the enum class Empty_String
  • I changed the check order because I don’t have to look for isograms if the Guess is empty or has uppercases.


bool FBullCowGame::IsLowercase(FString Word) const
{
	for (auto Letter : Word)
	{
		if (Letter != ' ' && Letter != '\0' && !islower(Letter)) { return false; }
	}
	return true;
}

Privacy & Terms