I have a class that is called ShapeBase. It is abstract and draw method must be implemented. It has instance variables for things like width and height. From this, Circle, Line, and Rectangle are subclasses and implement the draw method. The Line class does not have an isFilled property (get / set) but Rectangle, and Circle do. I could obviously just add the property to both separatly, but later on I may want to dynamically gather all shapes that can be ‘filled’. I thought of making a filled interface but, the problem is then I have to implement the getter and setter for both. In C++ I’d make use of multiple inheritance to solve this, but what can I do in Java to solve this kind of problem?
Thanks
You could have a
FillableShapeBasewhich is abstract and extendsShapeBasebut has the addedisFilledproperty with getters and setters.RectangleandCirclecould inherit fromFillableShapeBase.