7. Bina Nusantara Kemanggisan
Code using the concept of “objects”, implementing this paradigm is called
object-oriented programming
Object-oriented?
8. Bina Nusantara Kemanggisan
Code using the concept of “objects”, implementing this paradigm is called
object-oriented programming
Object-oriented?
9. Bina Nusantara Kemanggisan
Each object has its’ own attributes and functions. A constructor is usually made
to initialize the creation of an object.
Object-oriented?
10. Bina Nusantara Kemanggisan
1. Make classes, lots of classes!
2. Set class attributes.
3. Make a constructor!
Implementation
13. Bina Nusantara Kemanggisan
Attributes that are public can be accessed by any class.
Attributes that are protected can only be accessed by child classes.
Attributes that are private can only be accessed by the class itself!
Encapsulation
14. Bina Nusantara Kemanggisan
Easy! Just add public, protected or private in front of your attribute / function
i.e. private int price;
Implementation
17. Bina Nusantara Kemanggisan
A child has all the attributes and functions of its parents (not the other way around)
Inheritance
18. Bina Nusantara Kemanggisan
In Java inheritance can be implemented by using extends
i.e. public class Hatchback extends Car
In the example above, it means the class Hatchback is a child of the Car parent class.
Implementation
19. Bina Nusantara Kemanggisan
Polymorphism means “multiple forms”, essentially that is a literal
definition of polymorphism in object-oriented programming
Polymorphism
24. Bina Nusantara Kemanggisan
public int a(){
//functionstuff
}
public int a(int x){
//functionstuff
}
Implementation
This is an example of a overloading function. In
this example, function a could receive two types of
parameters none or when an integer is passed.
Thus we can choose to implement a certain
function by passing different parameters.