Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started