A class is composed of Attributes, Constructors, Behaviors, and Properties.
Attributes is a variable that is used within the class.
A constructor is what is used to set the values of the attributes. The attributes values can also be set without the use of a constructor.
Behaviors are methods that are within a class.
Properties are what are used to set the values of the attributes.
A normal class looks like the following:
One thing I always remember is that a class is an instance of an object. Meaning that a class represent, for example, a car. A car
is composed of color, speed, make, model, year, etc. All are considered attributes and properties can be set. A behavior could be "Move" which would move the car when called upon.
To use the class you would simple do:
There are many ways to set up a class, however I preffer the way that was shown on this example because for me it is easy to understand. As you get better you will understand that as you get better you will do one thing a certain way then whatever you made a few hours later you might say, "I could have done this, this way which could clean up the code a bit more and could have saved me a few seconds in typing a few extra lines of code.".
|
|