Suppose, you are writing a geometric engine. Now it includes classes Circle, Rectangle and interfaces Movable and Scalable.
You need:
to write a new interface
MutableShapethat extends both existing interfaces;to implement the new interface in each class;
to override methods
moveandscalein both classes:scaleshould multiply theradiusof a circle by the specifiedfactor;scaleshould multiplywidthandheightof a rectangle by the specifiedfactor;moveshould adddxanddyto the center of a circle;moveshould adddxanddyto the upper-left corner of a rectangle.
See the provided code and read comments to understand your task better. The code is not compiled.
Note:
do not remove existing classes and their members (including getters and constructors).
do not make your classes and interfaces
public
After your changes, the following code should be compiled:
MutableShape circle = new Circle(2.0f, 3.5f, 10.1f);
circle.move(10.1f, 20.2f);
circle.scale(2.2f);
((Circle) circle).getRadius();