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 271 Machine Problem 2- 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
Package-delivery services, such as DHL, offer a number of different shipping options, each has specific cost.
1. Write the header file and the implementation file for each of the following classes.
A class called PACKAGE as the base class: (10 points)
Data members of PACKAGE:
1. name 2. address 3. city 4. state 5. zipcode
(for both sender and receiver)
6. weight (in ounces)7. cost/ounce
Default constructor; initialize the data memebrs.
Constructor(s) 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: (10 points)
Data member to store:
1. Flat fee for the Two Days Package.
Default constructor initializes the fee to $10.99;
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: (10 points)
Data members to store:
1. Fee per ounce
Default constructor initializes the additional fee to $0.50 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.
2. 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. (20 ppints)
Your program should create two objects (TwoDay and the Overnight)
Your program/header 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!