Question: Assume given the following class definition: class RectangularLot { public: RectangularLot(); //default length is 1 and default width is 1 RectangularLot( double len, double wid
Assume given the following class definition:
class RectangularLot
{
public:
RectangularLot(); //default length is 1 and default width is 1 RectangularLot( double len, double wid );
void read(); // read the length and the width of the lot
void setLength( double len); // set the new value of the data member length void setWidth( double wid ); // set the new value of the data member width double getLength(); // returns the length of the lot
double getWidth(); //returns the width of the lot
double getArea(); // computes and returns the area of the lot
void print(); // prints the length, the width and the area of the lot private:
double length; double width;
};
- Write the definitions of the constructors and the other member functions of this class.
- Write the definition of the derived class of class RectangularLot named Lot4Sale as follows:
- It has an additional private data member named unitPrice (double precision value).
- In addition to the constructors, it has the following public member functions:
- double getUnitPrice( ) returns the value of the data member unitPrice.
- void setUnitPrice( double uprice ) sets the new value of the unit price.
- double getPrice( ) returns the price of the lot (the unit price times the area).
- Member function void read( ) is redefined in class Lot4Sale. It reads the unit price in addition to the length, and the width.
- Member function void print( ) is redefined in class Lot4Sale. It prints the unit price and the price of the lot (the unit price times the area) in addition to the length, the width, and the area.
- Write the definitions of the constructors (the default unit price is $1000.00), the functions read( ) and
print( ), and the new member functions of the class Lot4Sale.
- Assuming that objects lot1 and lot2 are defined as follows (in main.cpp file):
RectangularLot lot1( 80.00, 55);
Lot4Sale lot2( 120, 50, 5000.00);
What is the output produced by the following two statements:
lot1.print( );
lot2.print( );
You need to create 3 files, RectangularLot.h, RectangularLot.cpp, and main.cpp
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
