1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
frozen [14]
3 years ago
12

Use the script below as a starting point to create a Rectangle class. Your rectangle class must have the following methods;A con

structor that takes a length and width as parametersgetArea - returns the area of the rectangleisSquare - returns True if length and width are equivalentoverloaded equivalence - compares the length and width of two rectangles and returns true if they are equivalent
Computers and Technology
1 answer:
Greeley [361]3 years ago
4 0

Answer:

The solution code is written in Java.

  1. public class Rectangle {
  2.    private double length;
  3.    private double width;
  4.    public Rectangle(double length, double width){
  5.        this.length = length;
  6.        this.width = width;
  7.    }
  8.    public double getArea(){
  9.        return this.length * this.width;
  10.    }
  11.    public boolean rectangleSquare(){
  12.        if(this.length == this.width){
  13.            return true;
  14.        }else{
  15.            return false;
  16.        }
  17.    }
  18.    public boolean equivalence(Rectangle rect){
  19.        if(this.width == rect.width && this.length == rect.length){
  20.            return true;
  21.        }else{
  22.            return false;
  23.        }
  24.    }
  25. }

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.

You might be interested in
Which instrument is NOT an example of a chordophone?
Colt1911 [192]

Answer:

b. xylophone

Explanation:

7 0
3 years ago
One suggested means of gaining eye contact before reversing is to:____.
Orlov [11]

Answer:

<u>hit the vehicle horn</u>

<u>Explanation:</u>

Remember, a driver reversing may easily go unnoticed by pedestrians as the driver may be coming from behind. Thus, a suggested means of gaining the eye contact of pedestrians before reversing is to hit the vehicle horn.

5 0
3 years ago
A compressed file uses a(n) ____ as the last character in the file extension.
rjkz [21]
If it was done with the compress command, capital Z
6 0
3 years ago
I - For any two points on the Internet, there exists only one path between the two points II - Routing on the Internet is fault
sukhopar [10]

Answer:

I - False

II -True

Explanation:

For any communication between two points on the Internet, routing is to choose an optimum path.

But routing is also fault tolerant and redundant, which means that there are <em>alternative</em> paths to deal with possible problems and provide security during transmission.

4 0
3 years ago
A computer with 5 stage pipeline like the one descrive in class delas with conditional branches by stalling for the next three c
trasher [3.6K]

Answer:

It hurts 80%

Explanation:

7 0
3 years ago
Other questions:
  • What do u call a individual that loves motor bikes and leather and is in a rival group known as mods?
    5·1 answer
  • If you work up to your potential but fall short of your goals, you
    15·2 answers
  • NOS stands for _____.
    5·1 answer
  • What activities are the most likely to infect your computer with a virus? Check all that apply
    11·2 answers
  • Jennifer has written a business report. What should be her last step before she submits the story for publication?
    10·2 answers
  • again assume that each of the resistors in the circuit shown above has a resistance value of 100k(question in the picture above)
    9·1 answer
  • Question 21 pts How many lines should an email signature be? Group of answer choices "5 to 6" "7 to 8" "1 to 2" "3 to 4"
    10·1 answer
  • Bill is pushing a box with 10 N of force to the left, while Alice is pushing the box with 30 N of force to the right. What is th
    11·1 answer
  • 29. Write a program in a script file that calculates the cost of renting a car according to the following price schedule: The pr
    8·1 answer
  • Real estate management software
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!