Question: In Java please, comments would be a plus as well, Thank you! Design and implement a class named Rectangle which contains: Two instance variables of

In Java please, comments would be a plus as well, Thank you!

Design and implement a class named Rectangle which contains:

Two instance variables of double type: side1 and side2. Default values is 1.0.

One string instance variable (color) which defines the color of a rectangle. Default value is white.

All instance variables should be created as private

A non-argument constructor which creates a default rectangle.

A constructor which creates a rectangle with specified side1, side2 and color.

Set and get functions for each instance variable.

A method named calculateArea() which returns the area of a rectangle.

A method named calculatePerimeter() which returns the perimeter of a rectangle.

A method named toString() which returns the description of the rectangle. For example, Rectangle: two sides = + side1 + and the other two sides = + side2 + . Color: + color;

Write a driver class named TestRectangle that creates two rectangles. One of the rectangles should be created using non-argument constructor and the other rectangle with specified parameters. Print out their descriptions, areas and perimeters.

Draw UML diagram of Rectangle class that includes specified instance variables, methods, and constructors.

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!