Uncategorized

Inheritance Hierarchy Research Paper

Inheritance Hierarchy Research Paper

(Package Inheritance Hierarchy) Package-delivery services, such as FedEx??, DHL?? andUPS??, offer a number of different shipping options, each with specific costs associated. Create aninheritance hierarchy to represent various types of packages. Use Package as the base class of the hierarchy, then include classes TwoDayPackage and OvernightPackage that derive from Package. Baseclass Package should include data members representing the name, address, city, state and ZIP codefor both the sender and the recipient of the package, in addition to data members that store theweight (in ounces) and cost per ounce to ship the package. Package?s constructor should initializethese data members. Ensure that the weight and cost per ounce contain positive values. Packageshould provide a public member function calculateCost that returns a double indicating the costassociated with shipping the package. Package?s calculateCost function should determine the costby multiplying the weight by the cost per ounce. Derived class TwoDayPackage should inherit thefunctionality of base class Package, but also include a data member that represents a flat fee that theshipping company charges for two-day-delivery service. TwoDayPackage?s constructor should receivea value to initialize this data member. TwoDayPackage should redefine member function calculate-Cost so that it computes the shipping cost by adding the flat fee to the weight-based cost calculatedby base class Package?s calculateCost function. Class OvernightPackage should inherit directlyfrom class Package and contain an additional data member representing an additional fee per ouncecharged for overnight-delivery service. OvernightPackage should redefine member function calculateCostso that it adds the additional fee per ounce to the standard cost per ounce before calculatingthe shipping cost. Write a test program that creates objects of each type of Package and testsmember function calculateCost.

Is this the question you were looking for? If so, place your order here to get started!

×