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, <em>Rectangle</em> (Line 1) and define two private attributes,<em> width </em>and <em>length</em> (Line 3 - 4). The reason to define the attributes as <em>double</em> type is because the width and length are presumed to be either an integer or a decimal value.
Create constructor which takes <em>width</em> and<em> length </em>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.