0
/ 50
For the question below, assume the following implementation of the Measurable interface and Square and Circle classes:
public class Shape...
For the question below, assume the following implementation of the Measurable interface and Square and Circle classes:
public class Shape {
}
public class Circle extends Shape
{
private double radius;
public Circle(double newRadius)
{
radius = newRadius;
} // end constructor
public double getRadius() {
return radius;
}
public double getCircumference()
{
return 2.0 * Math.PI * radius;
} // end getCircumference
public double getPerimeter() // Measurable interface
{
return getCircumference();
} // end getPerimeter
public double getArea() // Measurable interface
{
return Math.PI * radius * radius;
} // end getArea
} // end Circle
public class Square extends Shape {
private double side;
public Square(double len) {
side = len;
}
public double getSide() {
return side;
}
public double getPerimeter() {
return 4 * side;
}
public double getArea() {
return side * side;
}
}
For this method, you will be writing a method that takes in a variable of type Shape:
Two static final objects (one square and one circle) have been provided to you, which may help you solve this problem.
Your feedback will appear here when you check your answer.