subject

Write a program that will manipulate Rectangle objects for which you will create a Rectangle class.

Declare a Rectangle class in a ".h" file with attributes and methods in the following points. Attributes should be private, methods should be generally public.

Define the Rectangle class in a ".cpp" file. Do not define anything inline in the ".h" file. Do not use 'namespace std' in either the .h or .cpp file of the class.

To use this class, write your main such that it will ask the user to input the two points and name for two rectangles. It will then calculate the result of the addition and subtraction operations. Then it will output the details of all 4 rectangles - to both screen and an output file. Allow the user to keep running the program in a loop, if desired.

A Rectangle is made up of two points (x. y) such that the first point (x1,y1) is the bottom left hand corner and second point (x2,y2) is the upper right hand corner. This will allow the Rectangle to be parallel to both axes.

Add a name attribute to the Rectangle which can be printed out from the program. Write two methods that return the area and perimeter of the rectangle respectively. Overload the input operator (>>) in the class to accept input for your class as needed. Do not use the cin operator in your class. Overload the output operator (<<) in the class such that it prints the following for a Rectangle object with name Rect1 (without the bullet points):

Rect1's four corners are at (5,3), (5,10), (8,10), (8,3).

Rect1's area is 21 and perimeter is 20.

Overload the addition operator (+) as a class member such that it returns the smalllest rectangle that will contain all four corners of both rectangles being added.

Overload the subtraction operator (-) as a friend function such that it returns a rectangle that is formed by the overlap of the two rectangles.

If there is no overlap between the two rectangles, it should return a rectangle where all four corners are at (0,0).

I do not understand the previous expert's comment of "dff". I am continuing to update this question in the hope that the expert will please inform me what information is needed so that a solution can be made.

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 01:10, kristofwr3444
Are special combinations of keys that tell a computer to perform a command. keypads multi-keys combinations shortcuts
Answers: 1
image
Computers and Technology, 23.06.2019 01:30, solikhalifeoy3j1r
In deadlock avoidance using banker’s algorithm, what would be the consequence(s) of: (i) a process declaring its maximum need as maximum possible for each resource. in other words, if a resource a has 5 instances, then each process declares its maximum need as 5. (ii) a process declaring its minimum needs as maximum needs. for example, a process may need 2-5 instances of resource a. but it declares its maximum need as 2.
Answers: 3
image
Computers and Technology, 23.06.2019 14:30, bernicewhite156
Select the correct answer. what does it indicate when a website displays https instead of http? a. the website is secure. b. there is no secure sockets layer. c. the secure sockets layer is hidden. d. the website is not secure.
Answers: 1
image
Computers and Technology, 23.06.2019 15:30, taapeters
Brian wants to conduct an online search with a certain phrase. he intends to use the words books that belong to the 1800s in his search. how should he use the word that in his search?
Answers: 1
You know the right answer?
Write a program that will manipulate Rectangle objects for which you will create a Rectangle class.<...

Questions in other subjects:

Konu
Mathematics, 19.06.2020 22:57