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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started