In C++:
Create a UML diagram for a Rectangle class. The diagram shouldinclude the following:
A pair of private double variables for the height and width ofthe Rectangle.
A default constructor that sets the height and width variablesto one.
A constructor that takes two arguments for the height andwidth.
Public accessor and mutator methods for the height andwidth.
The accessor methods should return doubles.
The mutators should have double parameters and returnnothing.
A method that returns the area of the Rectangle as a double.
A method that returns the perimeter of the Rectangle as adouble.
A method that returns a string stating that the object is aRectangle and listing the height, width, area, and perimeter of theRectangle.
The UML diagram should be a text or Word document and should beincluded in the project folder
********************
Then, using the UML diagram as a model, code a Rectangle class.Both the constructors and the mutator methods should be coded toset the Rectangle object's variables to one if the argument(s)passed in have a value less than one. The accessor methods(including the methods that return the area and perimeter) shouldbe a part of the class. So should the method that returns a stringdescription of the Rectangle object.
********************
Include a main function in your class file.
The main function creates a Rectangle object using the defaultconstructor and a second Rectangle object using the constructorthat takes arguments.
Modify the Rectangle object created with the default constructorusing the mutator methods.
Display the height, width, area, and perimeter of both objects(using the accessor methods).
For both objects, display the message returned by the methodthat returns a string description.
If you read the above closely, you'll see that the onlyvariables in your Rectangle class are the height and width. Why isthere no need for area and perimeter variables? Include a commentin your class that discusses that.
In C++: Create a UML diagram for a Rectangle class. The diagram should include the following: A pair of private double v
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am