Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the class diagram for a Shipping Calculator system given below: < > ShippingCost __________________________________ +calculateShippingCost(double): double UML class: FlatRateShipping implements ShippingCost __________________________________ -MAX_WEIGHT_ALLOWED: double

Consider the class diagram for a Shipping Calculator system given below:

<> ShippingCost __________________________________ +calculateShippingCost(double): double

UML class: FlatRateShipping implements ShippingCost __________________________________ -MAX_WEIGHT_ALLOWED: double -FLAT_RATE_COST: double _________________________________ +calculateShippingCost(double): double

UML class: StandardShipping implements ShippingCost ____________________________________ -BASE_WEIGHT: double -BASE_CHARGE: double -EXTRA_POUND_COST ____________________ +calculateShippingCost(double): double

UML Class: ExpressShipping extends StandardShipping ___________________________________________ -EXPRESS_MAIL_SURCHARGE: double ___________________________________________ +calculateShippingCost(double): double

For this problem, you will be writing code to meet the design outlined in the above diagram and will provide a driver class as well. A brief description of the interface and classes is given below:

ShippingCost: The abstract method in the interface takes one double parameter that specifies the weight of the package to be shipped. It returns the cost of shipping that package.

FlatRateShipping: Applies a flat rate for weight up to MAX_WEIGHT_ALLOWED. You can set the values for the two constants. If this option is chosen by the customer, as long as the weight of the package is less than or equal to the MAX_WEIGHT_ALLOWED, the cost of shipping would be the FLAT_RATE_COST.

StandardShipping: Applies a BASE_CHARGE per pound up to BASE_WEIGHT. Each additional pound is charged at EXTRA_POUND_COST. You can set the values for the two constants.

ExpressShipping: Applies an EXPRESS_MAIL_SURCHARGE to the standard shipping cost. You can set the values for the constant.

ShippingCalculator: This is a driver class that includes a main() method to exercise the various functionality. You will read the information about the packages to be shipped from a file.

Sample file: 4 Standard 15 Flatrate 60 Express 3 Standard 5

The first line includes the number of packages. You may assume that the files that you would read from would be of the exact same format as shown above. Create a ShipPackages.txt file that stores information about the packages to be shipped in the format provided above.

The information read should be used to create ShippingCost objects that will be stored in an array of type ShippingCost. Write a method called createPackagesToBeShipped() to achieve this.

Include a method in the ShippingCalculator class called computeAllShippingCosts() that will compute the shipping cost for all the packages and display the shipping option, package weight, and shipping cost.

Also, create a test class called ShippingCalculatorTests to test the functionality of the FlatRateShipping, StandardShipping, and ExpressShipping classes.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data Concepts, Theories, And Applications

Authors: Shui Yu, Song Guo

1st Edition

3319277634, 9783319277639

More Books

Students also viewed these Databases questions

Question

Why is the System Build Process an iterative process?

Answered: 1 week ago