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
Liquid water can change into a gas and become part of the air. When water is a gas, what is it called?
liq [111]
The term that is used to describe water in the gaseous state would be C. Water vapour.
3 0
3 years ago
Subscribe to epic beast brothers thank you
nikdorinn [45]
No ono moñón Ik Jkjkjk
5 0
3 years ago
All of the following can be caused by the movement of geologic plates EXCEPT
Aleks04 [339]
I think storm surges cause fro means world "earth" so a storm surge is like a flood SO plates would cause earth quakes and stuff
8 0
3 years ago
During prereading, it is not important to pay attention to visual aids. please select the best answer from the choices provided
Nadusha1986 [10]
True Because the visual aids will provide better hand to eye coordination
7 0
1 year ago
A device is sending out data at the rate of 1000 bps. How long does it take to send
vredina [299]

Answer:

0.01 second ; 0.008 seconds; 800 seconds

Explanation:

Given that:

Sending rate = 1000 bps

Rate of 1000 bps means that data is sent at a rate of 1000 bits per second

Hence, to send out 10 bits

1000 bits = 1 second

10 bits = x

1000x = 10

x = 10 / 1000

x = 0.01 second

2.)

A single character 8 - bits

1000 bits = 1 second

8 bits = (8 / 1000) seconds

= 0.008 seconds

3.)

100,000 characters = (8 * 100,000) = 800,000

1000 bits = 1 second

800,000 bits = (800,000 / 1000)

= 800 seconds

4 0
2 years ago
Other questions:
  • Changeover means that ____. (select all that apply)
    7·2 answers
  • Consider a multiprocessor CPU scheduling policy. There are 2 options: 1) a singlecommon ready queue of jobs; when a CPU becomes
    8·1 answer
  • How is IT related to new business initiatives?
    6·1 answer
  • You want to join your computer to a homegroup but you don't see any homegroups on your home network
    11·1 answer
  • Can someone help me with the 2.4 code practice question 2 on Edhesive???
    6·1 answer
  • You have just finished upgrading the 250 w power supply in your desktop computer to a 450 w power supply. now the bios doesn't r
    7·1 answer
  • What does the binary odometer show about representing large numbers​
    15·1 answer
  • Suppose a host has a 1-MB file that is to be sent to another host. The file takes 1 second of CPU time to compress 50%, or 2 sec
    12·1 answer
  • Write a Racket two-way selection structure that will produce a list '(1 2 3) when the first element of a list named a_lst is ide
    13·1 answer
  • What types of printed information are useful to obtain from your target employers?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!