Question: Write a Rectangle class to hold the length and the width. Write the obvious constructor. Write the toString () method for the class. Revise your

Write a Rectangle class to hold the length and the width.

Write the obvious constructor.

Write the toString() method for the class.

Revise your constructor above such that it has the ability to detect which input is the length and which one is the width. You will need to use the if statement here.

Write a constructor that takes two points as parameters. Create a Point class to assist you. Do not store these points. What must be stored is the lengths of the two sides, just as before.

Write a method to compute the perimeter of the rectangle.

Write a method to compute the area of the rectangle.

Write a method that returns a new Rectangle that is as double as the original one. Do not change the existing object.

------------------

Write a new class called TestRectangle, which contains the main method in order to test your classes. In the main method do the following tasks:

1.Create two rectangle objects

2.Create two point objects

3.Create a third rectangle using the above two points.

Print out the perimeter and the area of the rectangle objects

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 Databases Questions!