FBullCowCount FbullCowGame::SubmitGuess(FString Guess)
{
// increment the turn number
MyCurrentTry++;
// steup a return variable
FBullCowCount BullCowCount;
// loop through all letters in the guess
int32 HiddenWordLength = MyHiddenWord.length();
for (int32 i = 0; i < HiddenWordLength; i++)
{
for (int32 j = 0; j < Guess.length(); j++)
{
if (MyHiddenWord[i] == Guess[j])
{
if (i == j) { BullCowCount.Bulls ++; }
else { BullCowCount.Cows++; }
}
// compare letters against the hidden word
// if they match then
// increment bulls if they are in the same place
// increment cows if they are not
}
}
return BullCowCount;
Welcome to Bull Cow Game, a fun word game.
Can you guess the 9 letter isogram I’m thinking of?
Try 1. Enter your Guess: planet
Bulls = 6. Cows = 0
You guessed: planet
Try 2. Enter your Guess: bob
Bulls = 0. Cows = 0
You guessed: bob
Try 3. Enter your Guess: paanet
Bulls = 5. Cows = 1
You guessed: paanet
Try 4. Enter your Guess: