Interface is important. Without it you cannot interact with a program / machine / what-have-you.
Yet, if interface "wiring" is interspersed with "regular wiring", this usually signifies a messy design.
In your code, the "user interface wiring" is just so interspersed with "regular logic" of your program. That is, the code that you've written for randomizing the number, checking the range limits, etc. mingles and mixes with the code that was written just to let user know something or get user inputs.
That is OK for start. But once your apps will grow, you will want to have this separated. It's good to learn this early.
How to encapsulate? Enclose code dealing with it in a class.
How to abstract it? Have proper API (methods) in that class. Not getX setY etc., methods that actually mean something and that do something for you. Methods you would announce to the public and have them use it. Think of it like this: heart of your program, it's core logic, should be talking to your interface code. Not mingle but converse. They aren't one and the same.
Interface is important. Without it you cannot interact with a program / machine / what-have-you.
Yet, if interface "wiring" is interspersed with "regular wiring", this usually signifies a messy design.
In your code, the "user interface wiring" is just so interspersed with "regular logic" of your program. That is, the code that you've written for randomizing the number, checking the range limits, etc. mingles and mixes with the code that was written just to let user know something or get user inputs.
That is OK for start. But once your apps will grow, you will want to have this separated. It's good to learn this early.
How to encapsulate? Enclose code dealing with it in a class.
How to abstract it? Have proper API (methods) in that class. Not getX setY etc., methods that actually mean something and that do something for you. Methods you would announce to the
publicand have them use it. Think of it like this: heart of your program, it's core logic, should be talking to your interface code. Not mingle but converse. They aren't one and the same.