The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 406 Weeks Ago, 6 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
(Package Inheritance Hierarchy) Package-delivery services, such as FedEx®, DHL® and
UPS®, offer a number of different shipping options, each with specific costs associated. Create an
inheritance 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. Base
class Package should include data members representing the name, address, city, state and ZIP code
for both the sender and the recipient of the package, in addition to data members that store the
weight (in ounces) and cost per ounce to ship the package. PackageÂ’s constructor should initialize
these data members. Ensure that the weight and cost per ounce contain positive values. Package
should provide a public member function calculateCost that returns a double indicating the cost
associated with shipping the package. PackageÂ’s calculateCost function should determine the cost
by multiplying the weight by the cost per ounce. Derived class TwoDayPackage should inherit the
functionality of base class Package, but also include a data member that represents a flat fee that the
shipping company charges for two-day-delivery service. TwoDayPackageÂ’s constructor should receive
a 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 calculated
by base class PackageÂ’s calculateCost function. Class OvernightPackage should inherit directly
from class Package and contain an additional data member representing an additional fee per ounce
charged for overnight-delivery service. OvernightPackage should redefine member function calculateCost
so that it adds the additional fee per ounce to the standard cost per ounce before calculating
the shipping cost. Write a test program that creates objects of each type of Package and tests
member function calculateCost.
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll