Question: Write a program that is composed of one source file named Lab4a.cpp . The program instantiates and uses instances of a derived class with default
Write a program that is composed of one source file named Lab4a.cpp. The program instantiates and uses instances of a derived class with default and non-default constructors. The program must be written in accordance to the following plan:
Description
You should include a program description at the top of the main program according to the template. You may simply use this sentence, "The program instantiates and uses instances of a derived class with default and non-default constructors."
Write A Base Class
Declare a class named RealProperty that could be used to describe a piece of real property. It should contain these private fields:
streetAddress (string)
squareFootage (int)
taxes (double)
Use the data types in parentheses for the fields.
Each field should have a comment documenting what it is for.
Add the default constructor.
Add a constructor that accepts these data: street address (string), square footage (int), and taxes (double) .
Add mutator member functions to set the fields. One member function for each field. Each member function should begin with the word 'set' followed by the field name with the first letter changed to uppercase. Each member function should have a comment above the declaration describing its purpose.
Add accessor member functions to return the fields. One member function for each field. Each member function should begin with the word 'get' followed by the field name with the first letter changed to uppercase. Each member function should have a comment above the declaration describing its purpose.
Write the definition for the default constructor. The default constructor initializes the fields so that the street address is an empty string and all numeric fields are 0 or 0.0.
Write the definition for the other constructor which sets all the fields based on three parameters: street address, square footage, and taxes.
Write the definition for every member function.
Write A Derived Class
Declare a class named Apartment that could be used to describe a kind of real property. It is a class derived from RealProperty publicly. It should contain one private field:
monthlyRent (double)
Use the data type in parentheses for the field.
Each field should have a comment documenting what it is for.
Add the default constructor.
Add a constructor that accepts: rent (double) .
Add mutator member functions to set the fields. One member function for each field. Each member function should begin with the word 'set' followed by the field name with the first letter changed to uppercase. Each member function should have a comment above the declaration describing its purpose.
Add accessor member functions to return the fields. One member function for each field. Each member function should begin with the word 'get' followed by the field name with the first letter changed to uppercase. Each member function should have a comment above the declaration describing its purpose.
Write the definition for the default constructor. The default constructor initializes the fields so that the street address is an empty string and all numeric fields are 0 or 0.0. Note you need to use a special syntax to initialize the private fields of the base class.
Write the definition for the other constructor which sets all the fields based on four parameters: street address, square footage, taxes, and monthly rent. Note you need to use a special syntax to initialize the private fields of the base class.
Write the definition for every member function.
Declare a function named displayPropertyInfo that receives one reference parameter representing a real property. The function has no return value.
Declare a function named displayApartmentInfo that receives one reference parameter representing an apartment. The function has no return value.
Write the main function as follows:
Define and initialize an Apartment variable using the following data:
street address: Cupertino
square footage: 1200
taxes: 200
monthly rent: 2550.0
Call displayPropertyInfo and pass the Apartment variable.
Call displayApartmentInfo and pass the Apartment variable.
Write the definition of displayPropertyInfo below the main function.
Write the definition of displayApartmentInfo below the displayPropertyInfo function.
Test The Program
The output should look exactly as follows:
Property is located at: Cupertino Square footage: 1200 Taxes: 200 Apartment is located at: Cupertino Square footage: 1200 Taxes: 200 Monthly rent: 2550.00
Submit Lab4a.cpp
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
