I have an assignment with several abstract classes and including inheritance, but I've got a problem in a specific place of the assignment.
This is what I have (close up to the specific place where the problem going to happen):
public abstract class A {
//some fields
//constructor
//some functions
}
public abstract class B extends A {
//some fields
//constructor
//override functions
//some new functions
}
public abstract class C extends A {
//some fields
//constructor
//override functions
//some functions
}
/* class D that extends both B and C */
Now I need to create class D that extends class B and C.
I know that multiple inheritance can't be used in java so:
- I thought about delegate DP but I can't create 2 instances of class B and C (nor extend one and create instance of the other as they are both abstract).
- I also thought maybe extend the class with more complex functions/more fields and create interface of the other class but that will make me add all the fields from that class in my new class(I don't think it's the "right way").
- also I'm not sure if changing either of the already existing classes is what I need to do as the assignment.
in other words I'm lost...