Question: 1. Write a Rectangle class to hold the length and the width. 2. Write the obvious constructor. 3. Revise your constructor above such that it

1. Write a Rectangle class to hold the length and the width.
2. Write the obvious constructor.
3. 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.
4. Suppose there is no if statement in the language, how can you implement the
above question? (Hint: think of Math.min and Math.max).
5. 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.
6. Write a method to compute the perimeter of the rectangle.
7. Write a method to compute the area of the rectangle.
8. Write the toString() method for the class.
9. Write a method that returns a new Rectangle that is as double as the original one.
Do not change the existing object.
****In java please and clear ***

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!