A question about max value?

Hi i just wonder something.
In video of number Wizard game lessons (section 2 video 14 : Calculate Guess Variable)
max = 1000; and While guessing the number we found a bug stucked 999.
For getting rid of the tiny bug : int max updated as “max = max + 1;” in void start
With that way we could guess the max number too which is 1000 and we fixed it.
What about we changed the max as “max = 1001;” in public class. Not in Void Start!
It is also working and dont know why but this way makes much more sense to me.
Is it also proper way? or not? thanks…

I had the same question. And as I thought about it, the answer was simple. Max was not 1001 but only 1000. (I also tried it and saw that it worked.)

I looked at it this way:

If max is 1001 in public class, the issue is not solved. You still have to reach max. In order to get the bug gone, you would still have to add 1 somewhere else in order to reach 1001 which you declared as your new max in public class. It would be like a little repeating cycle. Putting it in void solves this issue.

If you keep adding 1 in “public class” , that number will never be reached when pressing up unless you keep adding 1 over and over. It negates the max of being 1000.

At least that’s how I see it. I have no experience but that’ s the conclusion I came up with.

Jenn

It is definitely make much more sense now. tahank you so much Jenn ^___^

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms