Created
June 9, 2017 20:58
-
-
Save anonymous/fb7fd9b998946ffedf87603df3234abc 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]) | |
{ | |
if (MyHiddenChar == MyGuessChar) | |
{ | |
BULL_COW_COUNT.Bulls++; | |
} | |
else if (MyGuessChar == 5) | |
{ | |
break; | |
} | |
else | |
{ | |
BULL_COW_COUNT.Cows++; | |
} | |
} | |
else if ((MyHiddenChar == 5)||(MyGuessChar == 5)) | |
{ | |
break; | |
} | |
} | |
} | |
return BULL_COW_COUNT; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
HI, that's pretty much as my attempt - except I didn't add the trapdoors for overlength guesses :)
/* receives a VALID guess and increments try # and returns count */
FBullCowCount FBullCowGame::SubmitGuess(FString Guess)
{
// increment try
MyCurrentTry++;
}