Answered step by step
Verified Expert Solution
Link Copied!

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 05_Rectangle project contains the following Rectangle class in the Rectangle.h
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 5 and 10,
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 to_string 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 Rectangle.h file, implement them in the Rectangle.cpp
file, and test them in the main.cpp 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 5 x 10 rectangle is congruent with a 10 x 5 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 non-member friend
functions. Make sure to write their prototypes and make them friends of the class in the Rectangle.h
file, implement them in the Rectangle.cpp file, and test them in the main.cpp 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 bug-free.
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
1 #ifndef RECTANGLE_H
#define RECTANGLE_H
#include r
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Nested Relations And Complex Objects In Databases Lncs 361

Authors: Serge Abiteboul ,Patrick C. Fischer ,Hans-Jorg Schek

1st Edition

3540511717, 978-3540511717

More Books

Students also viewed these Databases questions

Question

Briefly describe the difference between DAC and RBAC.

Answered: 1 week ago

Question

How do books become world of wonder?

Answered: 1 week ago