Just showing my partial code Process Guess;
the isogram was not shown yet in class #63 (early returns) but i went a head and implement a simple check of characters; as string is an array of characters , i used memberfunction GetCharArray() to access the array where string stores the characters and used a range base for loop to check the current character is equal to the next character by using pointer arithmetic. There is also alternative class for loop too instead of range based. I hope this is OK. I will see in the next sections. Great class )
void UBullCowCartridge::ProcessGuess(const FString& Input)
{
if (Input == HiddenWord)
{
PrintLine(TEXT(“You win…”));
EndGame();
return;
}
if (IsIsogram(Input))
{
PrintLine(TEXT("No repeating letters, guess again"));
return;
}
if (Input.Len() != HiddenWord.Len())
{
PrintLine(TEXT("The hidden word is %i letters long"), HiddenWord.Len());
PrintLine(TEXT("Sorry try guessing again! \n You have %i lives"), Lives);
// PrintLine(FString::Printf(TEXT("The hidden word is %2d characters long...\nTry Again.."), HiddenWord.Len()));
return;
}
PrintLine(TEXT("Lost a life"));
--Lives;
if (Lives <=0)
{
ClearScreen();
PrintLine(TEXT(“Sorry No More Lives”));
PrintLine(TEXT(“The HiddenWord was : %s \n”), *HiddenWord);
EndGame();
return;
}
PrintLine(TEXT(“Try again, You have %i lives left”), Lives);
}
bool UBullCowCartridge::IsIsogram(const FString& Guess)
{
for (auto& c : Guess.GetCharArray())
if (c == *(&c + 1)) return true;
//for(int i{0}; i < Guess.Len() - 1; ++i)
//{
// if (Guess.GetCharArray()[i] == Guess.GetCharArray()[i + 1]) return true;
//}
return false;
}