This is the logic I came up with before I move onto the next lesson. I tested it and it seems to work as intended. Does anyone have anything different outside of what is done in the video?
// receives a valid guess, increments turn, and returns count
FBullCowCount FBullCowGame::SubmitGuess(FString guess)
{
// increment the return #
MyCurrentTry++;
// setup a return variable
FBullCowCount BullCowCount;
int32 HiddenWordLength = MyHiddenWord.length();
int32 GuessingWorldLength = guess.length();
// loop through all letters in the guess
for (int32 i = 0; i < HiddenWordLength; i++)
{
// compared letters against the hidden word
for (int32 j = 0; j < HiddenWordLength; j++)
{
// if they match then
if (GuessingWorldLength == HiddenWordLength)
{
// if they're in the same place
if ((guess[i] == MyHiddenWord[j]) && (i == j))
{
// increment bulls
BullCowCount.Bulls++;
}
// else
else if (guess[i] == MyHiddenWord[j])
{
// increment cows
BullCowCount.Cows++;
}
}
}
}
return BullCowCount;
}