Question: using python What could I do to my code to fulfill assignment 7.1 (The Rectangle class) Following the example of the Circle class in Section

using python
What could I do to my code to fulfill assignment  using python What could I do to my code to fulfill
assignment 7.1 (The Rectangle class) Following the example of the Circle class
in Section 7.2, design a class named Rectangle to represent a rectangle.

7.1 (The Rectangle class) Following the example of the Circle class in Section 7.2, design a class named Rectangle to represent a rectangle. The class contains: Two data fields named width and height. A constructor that creates a rectangle with the specified width and height. The default values are 1 and 2 for the width and height, respectively. A method named getArea() that returns the area of this rectangle. A method named getPerimeter that returns the perimeter. Draw the UML diagram for the class, and then implement the class. Write a test program that creates two Rectangle objects-one with width 4 and height 40 and the other with width 3.5 and height 35.7. Display the width, height, area and perimeter of each rectangle in this order si Cdlelate rectangles height and width using functions import math def main(): #h is equal to height and w is equal to width heval(input("Enter the height of the rectangle: *)) w eval(input( Enter the width of the rectangle: ")) #print output print("The area of a", h, "x", w, "re print("The perimeter of a", h, "x", ctangle is", format (getArea(h, w), ".2f")) w, "rectangle is", format(getPerimeter(h, w), #function-t obtain area of a rectangle def getArea(h, w): return h * w #function-to bbtain perimeter st oWX def getPerimeter(h, w): return 2 *(h W) main() Have your program: Begin the program and each section with a comment. Define width and height as private data fields of the class Include the public methods getWidth() and getHeight) in the class Test these functions with calls from main) for the following two rectangles: 1) a 4 x 40 rectangle 2) a 3.5 x 35.7 rectangle Sample output: A 4 x 40 rectangle has an area of 160 and a perimeter of 88. All four numbers in bold above should be produced by four appropriate function calls to the getter methods of the class Create a UML (Unified Modeling Language) diagram for your Rectangle class. See Sections 7.5 and 7.6 and Figure 7.9, page 230, for an example on indicating private data fields in a UML Turn in copies of your UML diagram, program listing and output. Please stapile this assignment sheet to your printouts

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!