Created
June 9, 2017 23:18
-
-
Save anonymous/7ad9e200f81a43c84839bd7d6e92ad85 to your computer and use it in GitHub Desktop.
my code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FBullCowCount FBullCowGame::SubmitGuess(FString TheGuess) | |
{ | |
//increment turn | |
MyCurrentTry++; | |
//setup return variable | |
FBullCowCount BULL_COW_COUNT; | |
//loop through all letters in players guess | |
int32 HiddenWordLength = MyHiddenWord.length(); | |
for (int32 MyHiddenChar = 0; MyHiddenChar < HiddenWordLength; MyHiddenChar++) | |
{ | |
for (int32 MyGuessChar = 0; MyGuessChar < TheGuess.length(); MyGuessChar++) | |
{ | |
if (MyHiddenWord[MyHiddenChar] == TheGuess[MyGuessChar])//Checks if indexes are equal | |
{ | |
if (MyHiddenChar == MyGuessChar)//checks if values in indexes are equal then increase bulls | |
{ | |
BULL_COW_COUNT.Bulls++; | |
} | |
else if (MyGuessChar == HiddenWordLength)//exits inner loop when guess char index equals 5. | |
{ | |
break; | |
} | |
else | |
{ | |
BULL_COW_COUNT.Cows++;//if break not encountered, increase cows | |
} | |
} | |
else if (MyHiddenChar == HiddenWordLength)//exits outer loop when hidden char index equal 5. | |
{ | |
break; | |
} | |
} | |
} | |
return BULL_COW_COUNT; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment