Why MAX_TRIES?

We have myMaxTries, that can be changed, and then MAX_TRIES that can’t be changed…but we set myMaxTries to MAX_TRIES’ value. Well if myMaxTries is NOT constant, what’s the point? Yeah I understand creating a constant is so that it can’t be changed later on in the code, but myMaxTries is NOT constant. So what’s the point if we CAN change it, or, why not just “const int myMaxTries” ?

3 Likes

I think it’s to teach proper code etiquette. With multiple instances of the game running, you may choose to have a different number of tries for each user. Since the code reads the information of each user to create each game instance, my bet is that the code allows for greater scalability (and flexibility) as the complexity of the game increases.

1 Like

Hi @Denis_Delinger and dear Community,

just adopt this behaviour as early as much possible. For sure you don’t MUST declare it as a constant but it’s wise, when you know beforhand the variable will never changed, to declare it as a constant.

This course is on a very low level and the course-instructors are high-knowledge personal. Some things will later be clearly to you, trust me.

Kind regards
Kevin

Privacy & Terms