Question
Please answer this assignment using C++. Thank! The purpose of this assignment is to exercise operator overloading: To do this assignment, you must extend the
Please answer this assignment using C++. Thank!
The purpose of this assignment is to exercise operator overloading:
To do this assignment, you must extend the code you have developed for Shape class and Rectangle class (see attachment) to implement the following:
Add two new member functions non-member operator overloading and member operator overloading for Rectangle class only
+ : (union of two rectangles) for two specified rectangle objects, take a union of both rectangles and return the area of the union of two rectangles.
If there is an intersection between two rectangles, it returns the sum of the areas of both rectangles subtracted by the intersected area.
If there is no intersection between two rectangles, it simply return the sum of the areas of both rectangles.
* : (intersection of two rectangles) for two specified rectangle objects, take an intersection of both rectangles and return the area of the intersection of two rectangles.
If there is an intersection between two rectangles, it returns the intersection of the areas of two rectangles.
If there is no intersection between two rectangles, it simply return 0.
Implement both non-member operator overloading and member operator overloading for the following operators for all the classes whenever applicable
class. Please note that you should implement both non-member and member operator.
Add a main driver to test:
4 intersection test cases:
Intersected and member operator overloading
Not ntersected and member operator overloading
Intersected and non-member operator overloading
Not ntersected and non-member operator overloading
4 union test cases:
Intersected and member operator overloading
Not ntersected and member operator overloading
Intersected and non-member operator overloading
Not ntersected and non-member operator overloading
Drawing two house pictures from PA2 using "
* The existing code can be found here: https://www.chegg.com/homework-help/questions-and-answers/using-c-please-write-function-move-rectangle-horizontally-right-left-original-point-thanks-q44614613?trackid=Lw_XEa1l
* Attachment
Point: reference point Shape Double: area, circumference Getters and setters of attributes computeArea() computeCircumference()| Base class moveBy (anlnt) draw (length) draw (wd, ht) setLine Type(aChar) Abstract class Char: line type (*, _, +, 5, ...) Integers: width, Rectangle height char: line Type Implements the methods from Shape Inherits from Add setHeight(anlnt), Shape setBase(anlnt) Point: reference point Shape Double: area, circumference Getters and setters of attributes computeArea() computeCircumference()| Base class moveBy (anlnt) draw (length) draw (wd, ht) setLine Type(aChar) Abstract class Char: line type (*, _, +, 5, ...) Integers: width, Rectangle height char: line Type Implements the methods from Shape Inherits from Add setHeight(anlnt), Shape setBase(anlnt)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