This assignment is for SharpCoder
Inheritance and Interfaces
Overview In this homework, you will implement a system that
• reads in an inventory file,
• prints the inventory to the console, and
• ships items.
It requires you to use Java classes and interfaces rather than static functions as we did in previous
homework.
Basic Application In this homework, you will create the basic application that reads input from a datafile and writes
the results to the console. In the next homework, you will enhance the application by adding
database functionality.
Program Flow The following pseudocode shows the required flow of the program.
Begin
For each line in inventory file do
determine inventory type
based on type, create object to hold data
(FoodItem or Household Item)
populate item with appropriate data (weight, etc)
Store in inventory list
End
For each item in inventory list do
print item
End
For each household item in inventory do
determine shipping cost
print shipping cost
End
End
Program Output
For the supplied input file, the output should be as shown below (dates will be different!)
Item banana
-- Shelf Life: 5
-- Remove from Shelf: Thu Mar 12 22:07:56 CDT 2015
-- Calories: 200.00
Item bread
-- Shelf Life: 10
-- Remove from Shelf: Tue Mar 17 22:07:56 CDT 2015
-- Calories: 120.00
Item toaster
-- Weight: 5
Item washer
-- Weight: 200
Item toaster shipped. Shipping cost is $100.00
Item washer shipped. Shipping cost is $4,000.00
Business Rules There are two types of items tracked in the system: food items and household (durable) items.
• Food Items Food items are edible (we hope!) and perishable. An edible item has calories, while a perishable
item has a limited shelf life. The item must be removed from the shelf when it expires. The expi-
ration date is simply
expiration date = date placed in inventory + shelf life in days
• Household Items Household items have unlimited shelf life, so they do not have an expiration date. They do have
(sometimes substantial) weight. Their weight is taken into account when determining the ship-
ping cost. The shipping cost is also higher when the item is shipped on the weekend.
UML Diagram The classes and interfaces required for the application have been defined for you, and are shown
in the diagram below. Dotted lines indicate interfaces while solid lines indicate inheritance. Your
application must implement all classes and interfaces as shown.
Javadoc The Javadoc for the application has been generated for you and is available as a
zip file. Unzip the file into a directory and then open the file index.html to view the
documentation.