Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Answer in C++ Define and implement the Rectangle2D class that contains: - Two double data fields named x and y that specify the center of

Answer in C++

image text in transcribed

image text in transcribed

Define and implement the Rectangle2D class that contains: - Two double data fields named x and y that specify the center of the rectangle with constant get functions and set functions. (Assume that the rectangle sides are parallel to x- or y-axes.) - The double data fields width and height with constant get functions and set functions. . A no-arg constructor that creates a default rectangle with (0, 0) for (x, y) and 1 for both width and height. a A constructor that creates a rectangle with the specified x, y, width, and height. . A constant function getArea) that returns the area of the rectangle. a A constant function getPerimeter) that returns the perimeter of the rectangle. a A constant function contains(double x, double y) that returns true if the specified point (x, v) is inside this rectangle. See Figure (a). - A constant function contains(const Rectangle2D &r) that returns true if the specified rectangle is inside this rectangle. See Figure (b). . A constant function overlaps(const Rectangle2D &r) that returns true if the specified rectangle overlaps with this rectangle. See Figure (c). a Implement the destructor and copy constructor to perform a copy in the class In the destructor cout a message that shows the destructor is called. fe) (a) A point is inside the rectangle. (b) rectangle is inside another rectangle. (c) A reclangle overlaps another rectangle FIGURE Write a test program that creates three Rectangle2D objects rl(2, 2, 5.5, 4.9), r2(4, 5, 10.5, 3.2)), and r3(3, 5, 2.3, 5.4), and displays rl's area and perimeter, and displays the result of rl.contains(3, 3), rl.contains(r2), and r1, overlaps( 3)

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_2

Step: 3

blur-text-image_3

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

Practical Azure SQL Database For Modern Developers Building Applications In The Microsoft Cloud

Authors: Davide Mauri, Silvano Coriani, Anna Hoffma, Sanjay Mishra, Jovan Popovic

1st Edition

1484263693, 978-1484263693

More Books

Students also viewed these Databases questions