Question: abstract class Shape { protected String color; protected boolean filled; public Shape ( String color, boolean filled ) { this.color = color; this.filled = filled;
abstract class Shape
protected String color;
protected boolean filled;
public ShapeString color, boolean filled
this.color color;
this.filled filled;
abstract double getArea;
abstract double getPerimeter;
public String toString
return "Shapecolor color filled filled ;
class Circle extends Shape
private double radius;
public CircleString color, boolean filled, double radius
supercolor filled;
this.radius radius;
@Override
double getArea
return Math.PI radius radius;
@Override
double getPerimeter
return Math.PI radius;
class Rectangle extends Shape
private double width;
private double length;
public RectangleString color, boolean filled, double width, double length
supercolor filled;
this.width width;
this.length length;
@Override
double getArea
return width length;
@Override
double getPerimeter
return width length;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
