Original Post
Hi people just learning java and was wondering if I could get some help on this because I just cant wrap my head around this 'no multiple inheritance' stuff. So I get that a class can only inherit one class but can implement multiple interfaces. But I cant understand how to get this into code. Heres a task iv been sent and have been provided this diagram to show how multiple inheritance can be achieved:
The objective of this task is to use java interfaces and delegation (composition) in order to simulate multiple inheritance 1- Objective: you will define the following class hierarchy: – Student, with a Name with a Unumber – Employee, with a salary – EmployedStudent, a person with a Unumber and a salary Unumber and salary are private data, instanciated by the constructors. You will define getter methods. 2- The Trick: Implement this hierarchy, using classes and an additional interface (or several additional classes and interfaces), so that the code in EmployedStudent members is reduced to a minimum of calls to the other classes methods. Please someone show me in detail as to what im doing here! In the image is 'superclass' the employee and 'delegate' the student with 'myclass' being the EmployedStudent? Any help would be greatly appreciated.
The objective of this task is to use java interfaces and delegation (composition) in order to simulate multiple inheritance 1- Objective: you will define the following class hierarchy: – Student, with a Name with a Unumber – Employee, with a salary – EmployedStudent, a person with a Unumber and a salary Unumber and salary are private data, instanciated by the constructors. You will define getter methods. 2- The Trick: Implement this hierarchy, using classes and an additional interface (or several additional classes and interfaces), so that the code in EmployedStudent members is reduced to a minimum of calls to the other classes methods. Please someone show me in detail as to what im doing here! In the image is 'superclass' the employee and 'delegate' the student with 'myclass' being the EmployedStudent? Any help would be greatly appreciated.