Question: CPS 2 7 1 Machine Problem 2 - Inheritance Objectives: implement a class and composition. To use the dynamic allocation to store objects and their
CPS Machine Problem Inheritance
Objectives: implement a class and composition.
To use the dynamic allocation to store objects and their data.
To use default constructor and overload constructor with full parameters.
To use setter functions and getter functions.
To use constant and static members.
To use Inheritance
To use override functions
Packagedelivery services, such as DHL offer a number of different shipping options, each has specific cost.
Write the header file and the implementation file for each of the following classes.
A class called PACKAGE as the base class: points
Data members of PACKAGE:
name address city state zipcode
for both sender and receiver
weight in ounces costounce
Default constructor; initialize the data memebrs.
Constructors with parameters set the data members according to the parameters.
Setter Functions to set the data members according to the parameters.
Getter Functions to return the data members.
Function to calculate the cost of the package
Function to output the data members in the form:
Name
Address
city, state zipcode
cost
A class called TwoDayPackage derived from PACKAGE: points
Data member to store:
Flat fee for the Two Days Package.
Default constructor initializes the fee to $;
Constructor with parameters.
Setter Function to set the data member
Getter Function to return the data member
An override Function calculate the cost by adding the fee to the cost that was calculated in the base class.
A class called OvernightPackage derived from PACKAGE: points
Data members to store:
Fee per ounce
Default constructor initializes the additional fee to $ per ounce;
Constructor with parameters.
Setter Function to set the data member
Getter Function to return the data member
An override Function calculate the cost by adding the additional fee per ounce to the standard cost before calculating the shipping cost that was calculated in the base class.
Write a main program Dem to test the reliability and validity of the above classes by showing the results of most of the functions you built. ppints
Your program should create two objects TwoDay and the Overnight
Your programheader files should be submitted in addition to the output of the calculate cost for each object.
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
