Question: ( Language is Python ) - Define the MyRectangle 2 D class that contains: o Two double data fields named x and y specify the
Language is Python Define the MyRectangleD class that contains:
o Two double data fields named x and y specify the center of the rectangle with getter and
setter methods. Assume that the rectangle sides are parallel to x or yaxes.
o The data fields width and height with getter and setter methods.
o A constructor that creates a default rectangle with for x y and for both width
and height.
o A method getarea that returns the area of the rectangle.
o A method getperimeter that returns the perimeter of the rectangle.
o A method containpointx y that returns true if the specified point x y is inside
this rectangle see Figure a
o A method containsrectangled that returns true if the specified rectangle is inside this
rectangle see Figure b
o A method overlapsrectangled that returns true if the specified rectangle overlaps
with this rectangle see Figure c
Task I: Draw the UML diagram for the class and then implement the class.
Task II: Write a test program that
creates a MyRectangleD object r with
displays the area and perimeter of r
displays the result of rcontainpoint
displays the result of rcontainsMyRectangleD
and roverlapsMyRectangleD
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
