| Pizentios |
Jan 29th, 2007 1:16 PM |
that a pretty basic Object Oreiented question. I would check out This here link and read it, mostly the part about Access modifiers.
What you are looking to do is setup some private varibles and a method to set the private varible and to get the current value of that varible. Private varibles can only be accessed from inside the class, which is why you have to have get and set methods.
let's say we have a class called Dog. In that class we would have to setup some varibles to hold the various attributes that a normal dog would have, like eye color, hair color, weight etc...
The varibles that actually hold the data for each dog should be set as private, because the data is speciffic to that Dog. When you code in OO, you reduce your programming time, because you reuse code.
So if you had lets say a program that stores a list of dogs, you would only have to code the Dog class once, and just reuse it. Every time you create a new dog you would use the Dog class constructor, which in turn would ether set the various attributes it's self or call the set methods of that class.
Don't worry that article that i posted above explains quite a bit. I think it will get you pointed in the right direction.
|