Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

NoRectangles (Int, Should Be Static. This Is A Counter Of The Number Of Rectangle Objects). 2- Write The Full-Argument Constructor, The No-Argument Constructor And The

NoRectangles (Int, Should Be Static. This Is A Counter Of The Number Of Rectangle Objects). 2- Write The Full-Argument Constructor, The No-Argument Constructor And The Side3 (Double) Side3 (Double) Side2 (Double) Side1 (Double) Name (String, Should Be Final) 1- Write A Class Rectangle That Has The Following Private Attributes/Fields:

1- Write a class Rectangle that has the following private attributes/fields:

name (String, should be final)

side2 (double) side1 (double)

side3 (double)

side3 (double)

noRectangles (int, should be static. This is a counter of the number of Rectangle objects).

2- Write the full-argument constructor, the no-argument constructor and the copy-constructor.

Note 1: the no-argument constructor and the copy-constructor need to call the full-argument constructor. The no-argument constructor sets name to InternalNameX, where X is the value of noRectangles, and it sets the sides to 1.0.

Note 2: validate the input in the full-argument constructor such that if the name is null it sets the attribute name to InternalNameX, where X is the value of noRectangles, and if the sides are not stricktly positive, it sets them to 1.0. It also must check the the values of the sides constitute a rectangle (side1 equals sides3 and side2 equals side4). If not, an IllegalArgumentException is generated.

3- Write the the getters and setters of all the attributes.

Note 3: validate the input in the setters according to Note 1.

4- Assuming the values of the sides constitute lengths in meter, overload two methods computeArea and computePerimeter (the return type of both is double) as follows:

If they take no argument they compute the area and the perimter in meter.

If they take one argument, then they check if the argument is cm (case insensitive) they return the area and the perimeter in centimeter, and if the argument is inch (case insensitive) they return the area and perimeter in inch. If the argument is none of these values, they throw an IllegalArgumentException.

Note 4: to convert from meter to inch multiply by 39.37.

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

Combinatorial Testing In Cloud Computing

Authors: Wei-Tek Tsai ,Guanqiu Qi

1st Edition

9811044805, 978-9811044809

More Books

Students also viewed these Programming questions

Question

What are the zeros of f (x) = 4 sin 2 x 3 on the interval [0, 2]?

Answered: 1 week ago

Question

Define Administration and Management

Answered: 1 week ago

Question

Define organisational structure

Answered: 1 week ago

Question

Define line and staff authority

Answered: 1 week ago

Question

Define the process of communication

Answered: 1 week ago

Question

Explain the importance of effective communication

Answered: 1 week ago