Mapa mental
Objects and Classes
Contenido del mapa
Objects and Classes
Classes
- Classes are the templates that are used to create objects
- For instance a class titles car could create two different objects
- Car 2
- color : red
- license plate : sp33d
- horsepower : 1000
- horsepower : 1000
- license plate : sp33d
- color : red
- Car 1
- color : blue
- license plate : 53jf1j4
- horsepower : 300
- although both cars are from the same class (or template) theyy are theyre own object
- horsepower : 300
- license plate : 53jf1j4
- color : blue
- Car 2
- For instance a class titles car could create two different objects
- Classes are declared using two pieces of information
- the class name
- what the class will be called
- It is common to capitalize the first letter of every word in a class name
- for example: ClassName
- the class body
- showing what information will be inserted into the class
- the class name
- Classes are the templates that are used to create objects
Objects
- Objects have two featurs
- actions (fields)
- for instance the object of a car would have the actions of accelerate, brake, park, etc.
- Fields are variables that can also refer to objects
- because of this it is posible that an object can contain other objects
- attributes (methods)
- for instance the object of a car would have the attributes color, number of tires, plate number etc.
- Methods are what define what an objects class is able to do
- to declare methods:
- returnType methodName (listOfArguments
- (the list of arguments can be empty though)
- returnType methodName (listOfArguments
- both of these are optional as some may have one and not the other, or some objects may have both
- actions (fields)
- Objects have two featurs
Also... every class must contain a constructor before creating an object
- the syntax for the constructor is..
- constructorName ( ListOfArguments) {
- [constructor body]
- }
- [constructor body]
- constructorName ( ListOfArguments) {
- the syntax for the constructor is..
Información
- Descripción
- Mapa Mental sobre Objects and Classes, creado por Logan Grimail el 26/01/2020.
- Creado por
- Logan Grimail
- Visitas
- 0
- Valoración