After renaming SubmitGuess to SubmitValidGuess, he said to double check it still works. When I did so , I found that the turn try wouldn’t increment even after submitting a 6 letter guess. I’m unsure why this is.
This is the code for submitting a valid guess :
`FBullCowCount FBullCowGame::SubmitValidGuess(FString Guess)
{
// increment the try number
MyCurrentTry++;
// setup a return variable
FBullCowCount BullCowCount;
// loop through all letters in the guess
int32 WordLength = MyHiddenWord.length();
for (int32 MHWChar = 0; MHWChar < WordLength; MHWChar++){
// compare letters against the hidden guess
for (int32 GChar = 0; GChar < WordLength; GChar++) {
// if they match then
if (Guess[GChar] == MyHiddenWord[MHWChar]) {
if (MHWChar == GChar) { //if they're in the same place
BullCowCount.Bulls++; //increment bulls
}
else {
BullCowCount.Cows++; //increment cows
}
}
}
}
return BullCowCount;
}`
This is the switch statement :
`// loop continually until the user gives a valid guess
Ftext GetValidGuess()
{
Ftext Guess = “”;
EGuessStatus Status = EGuessStatus::Invalid_Status;
do
{
// get a guess from the player
int32 CurrentTry = BCGame.GetCurrentTry();
std::cout << “Try.” << CurrentTry << " Enter your guess : ";
std::getline(std::cin, Guess);
EGuessStatus Status = BCGame.CheckGuessValidity(Guess);
switch (Status)
{
case EGuessStatus::Wrong_Length:
std::cout << "Please enter a " << BCGame.GetHiddenWordLength() << " letter word. \n";
break;
case EGuessStatus::Not_Isogram:
std::cout << "Please enter a isogram (a word with no repeating letters). \n";
break;
case EGuessStatus::Not_Lowercase:
std::cout << "Please use only lowercase characters. \n";
break;
default:
// assume the guess is valid
break;
}
std::cout << std::endl;
} while (Status != EGuessStatus::OK); // keep looping until we get no errors
return Guess;
}`
I’m really confused about this, any help at all would be greatly appreaciated.