Reference no: EM132269041
Your family runs a package delivery services which offer a number of different shipping options, each with specific costs associated. Make an inheritance hierarchy to represent various types of packages. Use Package (standard package) as the base class of the hierarchy, and then add two derived classes TwoDayPackage and OvernightPackage. In the base class (Package), it includes sender and recipient information, package weight in ounces and cost per ounce. Package class has a function calcCost() which allows derived classes to override with their own implementations. Derived class TwoDayPackage should inherit the functionality from base class, Package, but also includes its own data member that represents a flat fee for two day delivery services. OvernightPackage class inherits from Package class and also includes a fee which charges extra fee per ounce for overnight delivery services. Both classes will override the calcCost() and print() functions from the base class. Your program should contain the following functionality:
a. Make a base class named Package which has the following private data members
- weightInOuncewith double type
- costPerOuncewith double type
- senderNamewith string type
- senderZipwith string type
- recipientNamewith string type
- recipientZipwith string type
a. Package class should contain the following functions:
- constructor which initializes the private data members
- parameterized constructor to set the value for each private data members
- necessary get and set functions for each private data members
- double calcCost()- returns the cost of the package (weightInOunce*costPerOunce)
- void print()- displays the package information including type of package, sender, recipient, weight, and cost.[NOTE: use virtual function in order to be able to derive from this class]
a. Make a derived class named TwoDayPackage which inherits the functionality from based class, Package, but also include its own data member and functions.
- flatFeewith double type
- add necessary constructors and get and set functions forflatFee
a. Make a derived class named OvernightPackage which inherits from Package and also includes its own data member and functions.
- extraFeePerOuncewith double type
- add necessary constructors and get and set functions forextraFeePerOunce
a. Both derived classes will override the calcCost() and print() functions from the base class.
b. In your main program, Make an array of Package which holds a list of 5 packages. const int SIZE=5;
Package pkgList[SIZE]; [NOTE: recommend to use array of pointers to make it easier to manage derived classes]
c. Fill the pkgList array with each type of the package (3 TwoDayPackages and 2 OvernightPackages).
d. Display the package list with details of each package.