Define a class CRectangle to encapsulate length, width and related calculations according

to the UML diagram above. The getLength function returns the length and getWidth returns

the width. The setRect function prompts and gets input for the current object and the

showRect displays the data of the current object. The circumference function calculates the

circumference of the current object and returns it, and the area function calculates the

area and returns it. Function isLarger returns true if the area of the current object is

greater than the argument object.
Implement the member functions outside of class block to facilitate information

encapsulation. When display length, width, circumference and area, display with two

Now exercise the class in client code. Besides test every single functions of the class,

also do the following:
1. Make an array of 10 CRectangle rectangles (i.e., objects).
2. Loop through the rectangles on the array to output the length and width of each

3. Loop through the rectangles to reset the length and width to the values user input.
4. Now display the length, width, the circumference, and the area of each of these

5. Sort the rectangles in descending order based on area.
6. Display the length, width, circumference, and area of these rectangles again to

verify they are sorted.
7. House clean the code, Good Bye message, and then end the program

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.