Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

*10.13 (Geomern: the MyRectangle2D class) Define the MyRectang1e2D class that contains: Two double data fields named x and y that specify the center of the

*10.13 (Geomern: the MyRectangle2D class) Define the MyRectang1e2D class that contains:\ Two double data fields named

x

and

y

that specify the center of the rectangle with getter and setter methods. (Assume the rectangle sides are parallel to

x

- or

y

-axis.)\ The data fields width and hoight with getter and setter methods.\ A no-arg constructor that creates a default rectangle with

(0,0)

for

(x,y)

and 1 for both width and height.\ A constructor that creates a rectangle with the specified

x,y

, width, and height.\ A method getArea () that retums the area of the rectangle.\ A method getPerimeter () that retums the perimeter of the rectangle.\ A method contains (doublo

x

, doublo

y

) that returns true if the specified point

(x,y)

is inside this reetangle (see Figure 10.24a).\ A method contains (MyRectangle2D r) that returns true if the specified rectangle is inside this rectangle (see Figure J0.24b).\ A method overlaps (MyRectang1e20 f) that returns thue ir the specified rectangle overlaps with this rectangle (see Figure 10,24c).\ (a)\ (b)\ (d)\ FicuRe 10.24 A point is inside the rectangle, (b) A rectangle is inside another rectangle,\ (c) A rectangle overlaps another rectangle. (d) Points are enclosed inside a rectangle.

image text in transcribed
*10.13 (Geometn: the MyRectang1e2D class) Define the MyRectang1e2D class that contains: Two double data fields named x and y that specify the center of the rectangle with getter and setter methods. (Assume the rectangle sides are parallel to x= or y-axis.) - The data fields width and height with getter and setter methods. - A no-arg constructor that creates a default rectangle with (0,0) for (x,y) and 1 for both width and height. - A constructor that creates a rectangle with the specified x,y, width, and height. - A method getArea() that retums the area of the rectangle. - A method getPerimeter () that retums the perimeter of the rectangle. A method contains (double x, doublo y ) that returns true if the specified point (x,y) is inside this rectangle (see Figure 10,24a). - A method contains (MyRectangle2D r) that returns truo if the specified rectangle is inside this rectangle (see Figure 10.24b). - A method overlaps (MyRectangle2D ) that returns true if the specified rectangle overlaps with this rectangle (see Figure 10,24c). FicuRe 10.24 A point is inside the rectangle. (b) A rectangle is inside another rectangle, (c) A rectangle overlaps another rectangle. (d) Points are enclosed inside a rectangle

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

Students also viewed these Databases questions

Question

Consider this article:...

Answered: 1 week ago

Question

2. To compare the costs of alternative training programs.

Answered: 1 week ago

Question

1. The evaluation results can be used to change the program.

Answered: 1 week ago