I know that the request was to just suggest which functions should be made to be const, but I decided to just go down the list of our functions and write down why I think they should be made const or not.
-
void Reset(): I believe that this shouldn’t beconst. I haven’t gone any further, but I am pretty sure that this is gonna reset current tries at the least when we write it and will probably also generate a new word or change the length of the word depending on the features we implement.
-
int GetMaxTries(): We made this const already because it is one of our getters and it doesn’t need to alter any of our private variables. -
int GetCurrentTry(): This is the class’s sole other getter and as such is the function that we were tasked with making itconst. -
bool IsGameWon(): This function should only need to access private variables and has no reason to change, which is why I think that this function is a good candidate to be madeconst. -
bool CheckGuessValidity(std::string): This function is going to check if the player’s input is a valid guess so it is another good candidate to be madeconst.
Now I originally believed that bool CheckGuessValidity(std::string) would not be const because I thought that’s naturally where we are going to alter MyCurrentTry. After thinking about it during this exercise I realized that would create a side effect and that @ben said we should trying to avoid side effects.In the future, we will create a setter and the logic for incrementing the MyCurrentTry will be handled in a side effect free way.