OOP inheritance of attributes
I'm facing some issues in OOP with inheritance inside a class with
specific attribute. I have still not found an easy solution, but maybe I
don't have the good keywords.
OK so let's say i have the following classes :
public class Video{
}
public class Movie extends Video{
}
public class TVSerie extends Video{
}
Both Movie and TVSerie should have an attribute which is a list of actors.
However actors could be slightly different for TVSerie and Movie, so i
created the following Actors classes :
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 to access a list of Actor in an instance of Video
but I don't really know where to declare each list. Right now, I've added
a list of specific Actor for TVSerie and Movie, but it doesn't seem right
because i have to check the type of my Video instance to get a list of
specific actor while all i need is the parent actor.
Thanks for your help.
No comments:
Post a Comment