I'm trying to wrap my head around this inheritance problem I'm having. Here's my current situation:
So I have a planning that can be either a list of activities (class Activities
) or a list of things to do (class Todos
).
However, if I do this in Todos
:
private List<Todo> todos;
public List<Activity> getPlanning(){
return todos;
}
It says that the types are incompatible.
- Why are they incompatible?
Since Todo
extends from Activity
, aren't we certain that Todo
provides at least the same functionality as Activity
?
and perhaps more importantly:
- How do I adjust my design to make things work?
(I'm not an expert in UML so forgive me if there are some mistakes in my diagram)