Question
Consider the class diagram for a Shipping Calculator system given below: < > ShippingCost __________________________________ +calculateShippingCost(double): double UML class: FlatRateShipping implements ShippingCost UML class: StandardShipping
Consider the class diagram for a Shipping Calculator system given below:
<
UML class: FlatRateShipping implements ShippingCost UML class: StandardShipping implements Shipping Cost __________________________________ ____________________________________ -MAX_WEIGHT_ALLOWED: double -BASE_WEIGHT: double -FLAT_RATE_COST: double -BASE_CHARGE: double _________________________________ -EXTRA_POUND_COST +calculateShippingCost(double): double ____________________ +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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started