I am facing some problems in OOP with inheritance inside a class with a specific attribute. I still haven't found a simple solution, but maybe I don't have good keywords.
OK, so let's say that I have the following classes:
public class Video{ } public class Movie extends Video{ } public class TVSerie extends Video{ }
Both films and TVSerie must have an attribute, which is a list of participants. However, the actors may be slightly different for TVSerie and Movie, so I created the following classes of Actors:
public class Actor{ String name; String role; } public class MovieActor extends Actor{ double compensation; } public class TVSerieActor extends Actor{ boolean guestStar; int numberOfEpisodes; }
Basically all I want is access to the list of Actors in the video instance, but I donโt know where to declare each list. Right now, Iโve added a list of specific actors for TVSerie and Movie, but that doesnโt seem right, because I have to check the type of my video instance to get a list of a specific actor, while all I need is a parent actor.
Thanks for your help.
source share