Question: Rectangle Create a Rectangle class as a child of the PixelShape class. The Rectangle class should have integers for the length and width of the
Rectangle
Create a Rectangle class as a child of the PixelShape class. The Rectangle
class should have integers for the length and width of the rectangle. The
length and width must be positive integers. Note: the name data member
inherited from PixelShape of a Rectangle object is rectangle
The Rectangle class will contain the following public member functions:
A constructor with integer parameters for the rectangles length and width,
and a parameter for the pixel character. The constructor should have
default arguments of and respectively.
A virtual destructor.
A SetLength mutator function that takes an integer argument and updates the
length data member to the value of the argument if the argument is
positive, and leaves the object unchanged if the argument is not positive.
A GetLength accessor function.
A SetWidth mutator function that takes an integer argument and updates the
width data member to the value of the argument if the argument is positive,
and leaves the object unchanged if the argument is not positive.
A GetWidth accessor function.
A virtual overloaded operator that takes a double as its right operand
and returns a Rectangle reference a reference to the left operand The
operator should multiply the values of the length and width data members by
the right operand as long as the resulting lengths and widths are at least
If multiplying the length and width by the right operand would result in
a length or width that is less than the operation should leave the
object unchanged.
A virtual Print function that takes a bool parameter that specifies whether
or not to fill the interior of the shape with pixel characters. The bool
parameter should have a default argument of true. The Print function should
output the name of the shape on one line, followed by a pixel drawing of
the rectangle using the length as the vertical distance number of lines
and the width as the horizontal distance. Each pixel character should be
followed by a space. For example, if the length and width of object r are
and the function call rPrinttrue should output the following to the
standard output device using cout
rectangle
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
