User input limited to digits only and I ensure the max is greater than the min.
I’m (somewhat) new to Unity but have been a programmer for some time and have used C# some before. I somewhat geeked out on this one probably more than i should but feel i learned a good bit. I added a lie catch as well in an attempt to prevent trickery. It could maybe use some refinement as i didn’t test it all that well. There may be better ways to collect the input but this way was very helpful to me in better understanding how Update() works. I feel I’ve spent enough time on this project and am ready to move on so I am not going to continue with further improvements.
This is helpful, however as a beginner, it raises more questions.
Most of which I hope will be covered in later sessions, however I’m keen to ensure I understand what it is I’m using as a solution, rather than just accepting that this code is what I’m looking for and leaving it at that.
For example, what is significant about the “Private” indication? What is the difference between applying it to the code in your work and not applying it in the lectures?
Overall, I wanted to take away some of the shame of copying your code, so was rather proud that I managed to fix my own “bug”. At the Max Range Set step, I found it was repeating the question and not accepting the user input. I spent a good hour or so scouring through the GetUserInteger method, (correct terminology? or is it function?) before finding that I was probably jumping ahead, so tried looking through from the top, as opposed to assuming I knew where the problem was.
Sure enough, in the Void Update function the “Max” value it was searching for, it would not have located as it was looking for “max”, without the capitalization.
I can say that I understand some of the methodology behind the more advanced code in your example, however would never have thought or known to call upon it at this stage of my learning. Replicating it myself however will hopefully help down the line and I’m thankful for the lesson, as small as it was, that I learnt.
Hi, sorry for my late reply as i have been on hiatus over the holidays.
If you’ve been continuing on you probably have answered your own questions by now. Some of the things i added in that i already new about get taught later on and might just add confusion at an early stage. Like the use of Private to keep variable access to that class only; not needed, just good practice.
Regarding the use of the terms Method vs. Function, either term can be used really. But basically a Function is a procedure or piece of code that isn’t part of a class. A Method is part of a class.
I just finished my version of the random number game and discovered that in the Down arrow update section, that max needed to be max = guess - 1, to prevent a repeat of the guess number. I tested it a few times to confirm. It isn’t noticeable, except by chance, until the number range gets within single digits. It didn’t matter in the previous iteration as guess was decided by a fixed mathematical routine.