Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ program 1. Point:: a Point in a two-dimensional plane has an integer x coordinate value and an integer y coordinate value. 2. Rectangle: a

C++ program

1. Point:: a Point in a two-dimensional plane has an integer x coordinate value and an integer y coordinate value.

2. Rectangle: a Rectangle is a class that has three attributes: 1. Point type data that represent the top -left point of the rectangle. 2. integer length ; 3: integer width.

Write the appropriate class definition for Point class and Rectangle class with necessary constructors, mutator and accessor functions.

Write a function that will take two objects of Rectangle class as parameter and return whether they intersect or not.

Write a main function that will take inputs from the user for two rectangles. Each rectangle requires 4 sets of inputs.

1. x of top-left point.

2. y of top-left point

3. length

4. width

The main function will return the 4 set of coordinate values of the rectangles and whether they intersect or not. Print the 4 set of coordinate values of a rectangle in the following order.

1. Top -left point.

2. Bottom-left point

3. Bottom-right point

4. Top - right point

Sample input:

x of rectangle 1: 2

y of rectangle 1: 4

length of rectangle 1: 2

the width of rectangle 1: 3

x of rectangle 2: 4

y of rectangle 2: 3

length of rectangle 2: 2

the width of rectangle 2: 3

Sample Output;

Co-ordinates of rectangle 1: (2, 4), (2, 2), (5, 2), (5, 4)

Co-ordinates of rectangle 2: (4,3), (4,1), ( 7,1), (7, 3)

They intersect;

Pease show comments for the intersection method. I don't know how to implement the functions whether they intersect or not in programming. Thank you.

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

Big Data Fundamentals Concepts, Drivers & Techniques

Authors: Thomas Erl, Wajid Khattak, Paul Buhler

1st Edition

0134291204, 9780134291208

More Books

Students also viewed these Databases questions

Question

Explain the differences among HTTP proxy, gateway, and tunnel.

Answered: 1 week ago

Question

=+Why does the brand want to advertise?

Answered: 1 week ago

Question

3 How the market system answers four fundamental questions.

Answered: 1 week ago

Question

5 The mechanics of the circular flow model.

Answered: 1 week ago