Disclaimer: I know there are a lot of questions about polymorphism out there, but I couldn't find a suitable answer for my problem. If your Google-fu is better than mine, please forgive the dupe.
I have a model using inheritance, such as in the example below.
public abstract class Base {
// ...
}
public class ConcreteA extends Base {
// ...
}
public class ConcreteB extends Base {
// ...
}
And I also have a List<Base>
, which is composed of objects that are either ConcreteA
s or ConcreteB
s.
I need to generate a graphical view for each object in the list, but the resulting element is not the same for ConcreteA
s and ConcreteB
s.
How can I achieve this using OO principles?
Aucun commentaire:
Enregistrer un commentaire