My print code

I put both FOR loops in IsIsogram():

bool UBullCowCartridge::IsIsogram(FString Guess) const
{
    PrintLine(TEXT("Hidden word is: "));
    for (int i = 0; i < HiddenWord.Len(); i++)
    {
        PrintLine(TEXT("%c"), HiddenWord[i]);
    }

    PrintLine(TEXT("Guess word is: "));
    for (int i = 0; i < Guess.Len(); i++)
    {
        PrintLine(TEXT("%c"), Guess[i]);
    }

    // While not checked all characters in guess
    // Compare 1st character of guess with 1st character of HiddenWord
    // If no match, return false
    int i = 0;
    while (i < Guess.Len())
    {
        if (Guess[i] != HiddenWord[i])
        {
            return false;
        }
        i++;
    }
    
    return true;
}
2 Likes

Awesome job!

Privacy & Terms