Question: Package Delivery Services Using Inheritance Overview and Problem Description Package delivery services like FedEx etc offer a number of different delivery options each with a

Package Delivery Services Using Inheritance
Overview and Problem Description
Package delivery services like FedEx etc offer a number of different delivery
options each with a specific cost associated with it. Create an inheritance
hierarchy to represent various types of packages. The Base class is called
Package and there are two derived classes called TwoDayPackage and
OvernightPackage.
The UML diagram for the Package is given below.
Package
-name: String
-address: String
-city: String
-state: String
-ZIP: String
-weight_in_ounces: double
-cost_per_ounce: double
+Package(String name, String address, String city, String state, String
ZIP, double weight_in_ounces, double cost_per_ounce)// constructor
+calculateCost(): double // returns weight times cost
The derived class TwoDayPackage inherits from Package. In addition, it has a
field called flatfee that represents the flat rate that is charged for shipping
via this method. This class also redefines the calculateCost function to add
flatfee to the calculated cost done by the base Package class. Set the flatfee
to $3.50 and initialize in the derived class constructor
The derived class TwoDayPackage inherits from Package. In addition, it has a
field called flatfee that represents the flat rate that is charged for shipping
via this method. This class also redefines the calculateCost function to add
the additional cost per ounce for overnight shipping to the standard
calculated cost done by the base Package class.
The derived class OvernightPackage inherits from Package. In addition, it has
a field called overnightFee that represents the additional fee per ounce that
is charged for shipping via this method. This class also redefines the
calculateCost function to add flatfee to the calculated cost done by the base
Package class.
The toString method of the Package class is redefined by toString methods of
both derived classes.
Cost of Shipping per ounce =0.67 cents
Flat fee for two day shipping is 3.50
Fee for overnight shipping =0.45 cents
What to do?
A. Complete the UML diagram to include TwoDayPackage and Overnight
Package.
Make sure to add constructors, fields and methods appropriately
An example of how to do this is given below.
Here is a link to more learning material.
UML for Inheritance Relationships
Here is an example of how inheritance relationships can be represented using UML
Generalization: A class extends another class. For example, the Book class
might extend the Document class, which also might include the Email class.
The Book and Email classes inherit the fields and methods of the Document
class (possibly modifying the methods), but might add additional fields and
methods.
UML for Inheritance Classes Example: Here is an example UML for
inheritance classes. Document is the Base Class and Book and Email both are
derived classes that inherit from Document
write it in java

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!