-The Rectangle class) Design a class named Rectangle to represent a rectangle. The class contains:

1. Two double data fields named width and height that specify the width and height of the rectangle. The default values are 1 for both width and height.

2. A string data field named color that specifies the color of a rectangle. Hypothetically, assume that all rectangles have the same color. The default color is white.

3. A no-arg constructor that creates a default rectangle.

4. A constructor that creates a rectangle with the specified width and height.

5. The accessor and mutator methods for all three data fields.

6. A method named getArea() that returns the area of this rectangle.

7. A method named getPerimeter() that returns the perimeter.

Draw the UML diagram for the class. Implement the class. Write a test program that creates two Rectangle objects. Assign width 4 and height 40 to the first object and width 3.5 and height 35.9 to the second object. Assign color red to all Rectangle objects. Display the properties of both objects and find their areas and perimeters.

plz help me this is my project.......................

7 Years
Discussion Span
Last Post by Salem
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.