MyBullsCowGame playtest game bugs

IsLetter2isLetter0IsLetter3IsLetter4isLetter1
a bug that i found was the computer does not know the difference between a letter and another type of character. when i place a character that is not a letter it prints on the screen another type of error like, please enter all lowercase letters. also this game deals with words, which we do not want the user entering something that is not a letter. i attempted to implement the isLetter method. it does not give me a syntax error or anything, or any error but i’m wondering why its not working.please let me know.

1 Like

i commented out the parts that i did to implement the IsLetter method. so you can see if i did it wrong. the issue i’m asking about is when it runs, it does not do at all what i intend it to do, like if i have not created the method at all

1 Like

I got it to work by putting it as the first test in the CheckGuessValidity()-function, like so

EGuessStatus FBullCowGame::CheckGuessValidity(FString Guess) const
{
    if (!IsLetter(Guess)) // if the guess isn't letter
{
	return EGuessStatus::Not_A_Letter;
}
else if (!IsIsogram(Guess)) // if the guess isn't an isogram
{
....

So this is probably one of the things Ben talked about when saying the checks are or aren’t independent. Seems like the order might be important here.

The only other thing I see is that you have a comma after it in the enumerator, but I tried the same and that didn’t change the result.

PS! A great idea to check for this also.

This is pretty much how I got the lowercase check to work, just switched a few things around so it works for isalpha. BTW, thanks a lot. I didn’t know about isalpha :smile:
with this it shouldn’t matter which order the status checks are in.
NOTE: make sure your lowercase function actually works. type in
as
asas
asdf
Asdf
aSdf
asDf
asdF
ASDF
correctword

gonna do the same thing with isalpha and check each slot with a symbol

TMap<char, bool> IsL; //makes a list and makes the IsL bool for each letter. THIS IS VERY IMPORTANT
for (auto Letter : word) // does for each letter in word
{
IsL[Letter] = isalpha(Letter); // makes IsL[Letter] true if it’s a letter
if (IsL[Letter]) // if IsL is true
{
IsL[Letter] = true; // this saves the IsL bool for each letter
}
else
{
return false; // if it’s not a letter, return false
}
}
return true;

The check for lowercase is more or less useless as we could easily have made all string lowercase by using the built in tolower()-function, http://www.cplusplus.com/reference/cctype/tolower/

But again, I suspect this is included by Ben as a way to learn us things. :slight_smile:

Privacy & Terms