Question: class Rectangle extends Shape { private double width; private doubld length; public Rectangle ( ) { this.width = 0 ; this.height = 0 ; }

class Rectangle extends Shape{
private double width;
private doubld length;
public Rectangle(){
this.width=0;
this.height=0;
}
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);
}
@Override
public String toString(){
return "Rectangle[width="+ width +", height="+ height +"]";
public boolean equals(Rectangle obj){
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass()!= obj.getClass())
return false;
Rectangle other = Rectangle obj;
if (filled != other.filled)
return false;
if (color == null){
if (other.color != null)
return false;
} else if (!color.equals(other.color))
return false;
return true;
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!