Answered step by step
Verified Expert Solution
Link Copied!

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 Shape(String color, boolean filled){
this.color = color;
this.filled = filled;
}
abstract double getArea();
abstract double getPerimeter();
public String toString(){
return "Shape[color="+ color +", filled="+ filled +"]";
}
}
class Circle extends Shape {
private double radius;
public Circle(String color, boolean filled, double radius){
super(color, filled);
this.radius = radius;
}
@Override
double getArea(){
return Math.PI * radius * radius;
}
@Override
double getPerimeter(){
return 2* Math.PI * radius;
}
}
class Rectangle extends Shape {
private double width;
private double length;
public Rectangle(String color, boolean filled, double width, double length){
super(color, filled);
this.width = width;
this.length = length;
}
@Override
double getArea(){
return width * length;
}
@Override
double getPerimeter(){
return 2*(width + length);
}
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Persuading Your Audience Strategies for

Answered: 1 week ago