Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases A Beginners Guide

Authors: Andy Oppel

1st Edition

007160846X, 978-0071608466

More Books

Students also viewed these Databases questions

Question

LO2 Distinguish among three types of performance information.

Answered: 1 week ago