Funtions that I think should be const

I think only one should be const:
int GetCurrentTry() const;

The reason being that I believe we are going to want to change or add aspects and functionality of both bools inside our code:
bool IsGameWon();
bool CheckGuessValidity(std::string);

Why would IsGameWon change anything?

1 Like

I was thinking of trying something more with the function. I want to check if the player has gotten 6/8 or more words perfect inside IsGameWon to output a motivational message that will (hopefully) encourage the player to play again, something like; “Good job! You guessed 6/8 words perfectly! Let’s go for 8/8 next time!”.

So I think in my case IsGameWon changes things. :smile:

Thanks for the reply, this has made me think more about my code!
Also your the first person to reply to one of my posts thanks for that too DamM!
Have a nice day.

If you’re just checking states and then outputting a message, what’s being changed?

1 Like

Hi again DanM!

Now that you’ve ask me again, I think the function doesn’t change anything. We want it (in the lessons) to tells us just if game is won, so we can then do other stuff like maybe reset the game or close application.

I’ve put more thought to the output I want to create and it’s variables and come to the conclusion that I should leave IsGameWon() const

I saw that I was deviating from it’s purpose or rather I didn’t understand it well to begin with. It will make things much easy if the function stays const and then I create another function or implement the code I want in one that will run and check what I desire. Correct me if I’m wrong, as I’m still learning the basics.

Thanks again!
Have a awesome day!

1 Like

Now you’re thinking (with portals) :slight_smile:

1 Like

Privacy & Terms