Const getter methods

int GetCurrentTry();
bool CheckGuessValidity(std::string); // TODO make a more rich return value
bool IsGameWon();
I do not think these are good candidates for const at all. Explanation (opinion) below:

int GetCurrentTry(); - not a good candidate because the value of current try should change every time we take a guess at the isogram, since it is literally counting how many times have we tried to guess it.
boolCheckGuessValidity(std::string); -isn’t a good candidate either since it has to change values inside of it depending on the users answer every time the user would guess.
bool IsGameWon(); - its sole purpose is to change state when the game is won so making it unable to change wouldn’t do much good either.

I think int GetCurrentTry(); is a good candidate for const because it’s only acting as a getter method, i.e. its only purpose is to return the value of MyCurrentTry. Since it’s only returning the value, it has no need to change the value. The value of MyCurrentTry will be changed elsewhere, in a method such as SubmitGuess(), which will do what you’ve said and count how many guesses we’ve had.

I am glad that you are thinking about it, and taking interest in other people’s thinking.

But I was wayyy off, and you at least got started right and have a good logic in thought.

Good luck in the course and may we both do good with C++ and Unreal :slight_smile:

Privacy & Terms