Create a testrectangle class tests constructors


Discuss the below:

Create a Rectangle class with

- Private attributes for width and height

- A default constructor that sets the height to 10 and width to 25.

- An overloaded constructor that takes integer width and height arguments, uses a separate method to check whether the width and height fall within the range between 0 and 30, and throws an exception if out of range.

- getArea and draw methods for the class.

- getArea will calculate the area of the rectangle based on the width and height.

- draw will outline the rectangle using asterisks. The number of asterisks used will match the width and height of the rectangle.

Create a TestRectangle class that tests both constructors of the Rectangle class.

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Create a testrectangle class tests constructors
Reference No:- TGS01934354

Now Priced at $20 (50% Discount)

Recommended (92%)

Rated (4.4/5)