I have an interface (move) that should move some shapes.
interface Move { move(); }
abstract class Shape : Move
class Circle : Shape
class Square : Shape
class Triangle : Shape
My doubt is, I must have an interface which moves Shapes but only Circle and Triangle should be able to be moved, so how do I “remove” the interface from Square? Should I remove the interface from Shape and add it manually on Circle and Triangle? I’m kinda confused with this. Hope someone can help me out.
You should setup your classes like this:
If not every shape can be moved then
Shapemust not implement the interface. Also note I renamed your interface toIMovable, it’s not a huge deal but it’s more accepted and a better naming convention.