My personal candidates for "const"

My good candidates for the use of “const” in the function implemented so far are:

int GetMaxTries(); --> The name of the function itself tells us that its function is to get the number of max tries. So, nothing will be changed inside it.

int GetCurrentTry(); --> As above, just its function is to get the number of the current try. So, again, nothing will be changed inside it.

bool IsGameWon(); -->This function will return a boolean value. So, “true” or “false”. Again, nothing will be changed inside it.

bool CheckGuessValidity() --> This function will return a boolean value as well. It checks if the guess the user gave us is valid or not. So, again, nothing will be changed inside it.

These are my good candidates for the use of “const”. It remains only one function.

void Reset(); -->This function will be used to reset all the game and all the “stats” of the game. So, in my opinion, this function will be used to reset the MyCurrentTry value, the score (if it will be implemented) and so on. So, in this function, one or more class members will be changed.

1 Like

Agreed, from my perspective, checking if a guess is valid shouldn’t change anything. I get the impression that in future lectures it may, for instance, increase the current turn counter if the guess is valid, but I think this action should be kept within a different public method.

Agree too, I think these are the game`s mechanics and for that they must not be change at least there isnt a custom mode or something -

Privacy & Terms