Question: 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

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!