Question: python program geometry tool Description: Suppose you are a software engineer at Shepards, a software company focusing on developing simulation software and scientific computing tools.

python program geometry tool
Description: Suppose you are a software engineer at Shepards, a software company focusing on
developing simulation software and scientific computing tools. You are assigned to create a class
that can compute the attributes of a rectangle and the relationship between a rectangle and
another geometry object.
Below are the detailed requirements of the class that you need to develop.
Goals: Define the MyRectangle2D class that contains:
1. 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 y-axes.)
2. The data fields width and height with getter and setter methods.
3. A constructor that creates a default rectangle with (0,0) for (x, y) and 1 for both width
and height.
4. A method get_area() that returns the area of the rectangle.
5. A method get_perimeter() that returns the perimeter of the rectangle.
6. A method contain_point(x1, y1) that returns true if the specified point (x1, y1) is inside
this rectangle (see Figure 1a).
7. A method contains(rectangle_2d) that returns true if the specified rectangle is inside this
rectangle (see Figure 1b).
8. A method overlaps(rectangle_2d) that returns true if the specified rectangle overlaps
with this rectangle (see Figure 1c).
Task I: Draw the UML diagram for the class and then implement the class.
Task II: Write a test program that
a. creates a MyRectangle2D object r1 with (4,4,10.5,8.9),
b. displays the area and perimeter of r1,
c. displays the result of r1.contain_point (6,6),
d. displays the result of r1.contains(MyRectangle2D(8,10,20.5,6.2)),
e. and r1.overlaps(MyRectangle2D(6,10,4.3,10.4))

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!