Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Databases With Application To GIS

Authors: Philippe Rigaux, Michel Scholl, Agnès Voisard

1st Edition

1558605886, 978-1558605886

Students also viewed these Databases questions