Kevin Zhu wrote:Does anyone know whether it's common practice to use more than just field variables?
I just started learning java today and I read about private variables within a class (not the main class -- could the main class even have private variables?). I read that private is used to keep others from changing it outside of the class...
...so I figured that maybe one uses is keeping the variable within a certain range.
Hence, if you look at my constructor for Point, it has a conditional case, where one of them spits out a string.
Also, I don't have anything my in constructor for my Points class (last box). Is that a problem?
Could I also have somehow combined these classes? (I'm not even too sure when I need to create a class. It just seemed like a good idea to create two, or rather, it was easier for me.)
I did not do very well in my first computer science course so I would believe that there are a lot of things that I could simplify in my code. I'd appreciate it if anyone can give me useful tips.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
To earn money on java go to upwork.com
Volodymyr Levytskyi wrote:
Java class - is a text composed by developer according to some rules. That text is used by JVM to ...
Volodymyr Levytskyi wrote:Object exists to encapsulate certain methods! To peform methods an Object needs to keep some values(state), for this object uses variables.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Kevin Zhu wrote:
Does anyone know whether it's common practice to use more than just field variables?
Such as what?
Object exists to encapsulate certain methods! To peform methods an Object needs to keep some values(state), for this object uses variables.
New rule: no elephants at the chess tournament. Tiny ads are still okay.
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
|