I have an abstract class called GameCharacter, that has some methods I'm gonna require from Game Characters.
There is another abstract class called Cell, that represents different types of cells and the operations associated to them.
Not every Cell is transitable, and I need to set a GameCharacter only for a subtype of Cell called GroundCell that is transitable.
My question is:
If I want to implement (in Cell):
public abstract void setCharacter(GameCharacter character);
...and only define its body to do something in GroundCell, and just leave it empty for the other subtypes of Cell... Would this break the Interface Segregation Principle, or any other SOLID Principle at all?
I have a bad smell about defining a method in the supertype for one specific class, but I don't want to use InstanceOf() because it breaks the Open-Closed Principle.
If this is not a practical solution, what would be one that wouldn't break the modular design?
Aucun commentaire:
Enregistrer un commentaire