Respuesta :
Answer:
The solution code is written in Java.
- public class Rectangle {
- private double length;
- private double width;
- public Rectangle(double length, double width){
- this.length = length;
- this.width = width;
- }
- public double getArea(){
- return this.length * this.width;
- }
- public boolean rectangleSquare(){
- if(this.length == this.width){
- return true;
- }else{
- return false;
- }
- }
- public boolean equivalence(Rectangle rect){
- if(this.width == rect.width && this.length == rect.length){
- return true;
- }else{
- return false;
- }
- }
- }
Explanation:
Create a class, Rectangle (Line 1) and define two private attributes, width and length (Line 3 - 4). The reason to define the attributes as double type is because the width and length are presumed to be either an integer or a decimal value.
Create constructor which takes width and length as parameters (Line 6).
Next, the require methods, getArea(), isSquare() and overloaded equivalence() along with their expected parameters and return output, are created accordingly in Line 11 -28.