PEMROGRAMAN LANJUT Informatika FILKOM UB Semester Genap 2015/2016 PEWARISAN / INHERITANCE Contoh Hirarki Kelas Dr. Eng. Herman Tolle Program Teknologi Informasi & Ilmu Komputer, Universitas Brawijaya Contoh Inheritance Superclass-Subclass Example: Shared Functionality public class Student { String name; char gender; Date birthday; Vector<Grade> grades; public class Professor { String name; char gender; Date birthday; Vector<Paper> papers; double getGPA() { … } int getCiteCount() { … } int getAge(Date today) { … } int getAge(Date today) { … } } Java Programming: Program Design Including Data Structures } 4 public class Person { String name; char gender; Date birthday; int getAge(Date today) { … } } public class Student extends Person { public class Professor extends Person { Vector<Grade> grades; Vector<Paper> papers; double getGPA() { … } int getCiteCount() { … } } Java Programming: Program Design Including Data Structures } 5 UML Inheritance Diagrams • Figure 8.2 A class hierarchy in UML notation UML Inheritance Diagrams • Figure 8.3 Some details of UML class hierarchy from figure 8.2 Java Hirarki