Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Answer the following in C++ please, thank you. Assume given the following class definition: class RectangularLot { public: RectangularLot (); //default length is 1 and
Answer the following in C++ please, thank you.
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; \} 1. Write the definitions of the constructors and the other member functions of this class. 2. Write the definition of the derived class of class RectangularLot named Lot4Sale as follows: a. It has an additional private data member named unitPrice (double precision value). b. 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). c. Member function void read( ) is redefined in class Lot4Sale. It reads the unit price in addition to the length, and the width. d. 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. 3. List the following: a. All member functions of class Lot4Sale (each one with its access-specifier and its description). b. All data members of class Lot4Sale. List each one with its access-specifier and also indicate whether or not it is accessible in a new/redefined member function of class Lot4Sale. 4. 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. 5. Assuming that objects lot1 and lot2 are defined as follows: RectangularLot lot1( 80.00, 55); Lot4Sale lot 2( 120, 50, 5000.00); What is the output produced by the following two statements: lotl.print( ); lot2.print ( ); 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; \} 1. Write the definitions of the constructors and the other member functions of this class. 2. Write the definition of the derived class of class RectangularLot named Lot4Sale as follows: a. It has an additional private data member named unitPrice (double precision value). b. 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). c. Member function void read( ) is redefined in class Lot4Sale. It reads the unit price in addition to the length, and the width. d. 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. 3. List the following: a. All member functions of class Lot4Sale (each one with its access-specifier and its description). b. All data members of class Lot4Sale. List each one with its access-specifier and also indicate whether or not it is accessible in a new/redefined member function of class Lot4Sale. 4. 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. 5. Assuming that objects lot1 and lot2 are defined as follows: RectangularLot lot1( 80.00, 55); Lot4Sale lot 2( 120, 50, 5000.00); What is the output produced by the following two statements: lotl.print( ); lot2.print ( )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