Question: public interface Shape { public double getArea(); public double getPerimeter(); } For this problem, you will create 2 classes, Rectangle and Square, both of which

public interface Shape { public double getArea(); public double getPerimeter(); } For this problem, you will create 2 classes, Rectangle and Square, both of which will implement the Shape interface. The Rectangle class will contain exactly 2 properties: width and height. The getArea method will return the area of the rectangle, while the getPerimeter method will return the perimeter. The Square class will contain exactly one property: width. The getArea method will return the area of the square, while the getPerimeter method will return the perimeter. Implement both classes in the space below. Note that constructor methods have been implemented for you. public class Rectangle { //TODO: put properties here public class Square { //TODO: put property here public Rectangle(double w, double h) { height = h; width = w; } public Square (double w) { width = w; } //TODO: implement getArea method here //TODO: implement getArea method here //TODO: implement getPerimeter method here //TODO: implement getPerimeter method here } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
