Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This lab has been designed for you to practice implementing and testing overloaded operators for a Rectangle class. The 0 5 _ Rectangle project contains
This lab has been designed for you to practice implementing and testing overloaded operators for a
Rectangle class. The Rectangle project contains the following Rectangle class in the Rectangleh
file.
The width and length data members represent the width and length of a Rectangle shape.
You are given the following member functions:
The default constructor sets the width and length of a new Rectangle object to and
respectively.
A setWidth member function that takes one parameter and updates the width of the invoking
Rectangle object using the value of the parameter.
A setLength member function that takes one parameter and updates the length of the invoking
Rectangle object using the value of the parameter.
An area member function returns the area of the invoking Rectangle object.
A tostring member function returns a string that includes the width and length of the invoking
Rectangle object.
In part I, you are asked to overload some operators for the Rectangle class using member functions.
Make sure to write their prototypes in the Rectangleh file, implement them in the Rectanglecpp
file, and test them in the maincpp file.
Overload the operator to compare two Rectangle object. It shall return true if the two rectangles
are congruent and false otherwise. Two rectangles are congruent if they can have the same shape
and size. In other words, they both have the same width and length, or the width of the first
rectangle is the same as the length of the second and the length of the first is the same as the width
of the second. For example, a x rectangle is congruent with a x rectangle. The following
illustrates the results of some sample testing:
Overload the operator to increase the length and width of the invoking Rectangle object by an
unsigned value. The following illustrates the results of some sample testing:
In part II you are asked to overload some operators for the Rectangle class using nonmember friend
functions. Make sure to write their prototypes and make them friends of the class in the Rectangleh
file, implement them in the Rectanglecpp file, and test them in the maincpp file. Use the example
sample runs from part I as models to design your own tests for the other functions in part II Be sure to
test thoroughly, remember, your goal when testing is to try to break your code! If you cannot find a way
to make your functions break, then you know they are more likely to be bugfree.
Overload the operator to compare two Rectangle object. It shall return true if the Rectangle object
on the left has a larger area than the Rectangle object on the right.
Overload the operator to compare an unsigned value on the left against a Rectangle object on the
right. The comparison shall return true if the area of the Rectangle object is not the same as the
unsigned value.
Overload the operator to display a message about the width and length of the Rectangle object
on the right of
Rectangle.h
#ifndef RECTANGLEH
#define RECTANGLEH
#include
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