When comparing string attributes of packages (e.g. the address), assume that comparisons are string insensitive (e.g. "ABC Company" is the same as "abc Company"). |
In this project, you will implement a class to model a delivery truck. Since delivery trucks can carry any type of cargo, it is appropriate to design and implement the truck using Java generics. You will also implement classes to model boxes, cans, and sacks carried in the truck.
Your project will instantiate one delivery truck. The truck will load packages (boxes, cans, and sacks), drive from one destination to another, deliver packages, and print an inventory of the truck's contents. Commands read from a command file direct your truck. Output from your project will be displayed on the screen and also written to a text file.
This project will retrieve some input from the command line. The command line will have three arguments:
For this project, you will implement a generic Truck class and a class named Project5, whose only purpose is to contain the code for main() and main()'s helper methods. You will also implement a hierarchy of package classes, with Package as the base class and Box, Can, and Sack as its derived classes.
Since a truck can carry any kind of package, the truck will be implemented using Java generics.
Our truck has the following attributes. Other private attributes may be added if you find them helpful in your implementation
equals
, toString
,
etc.Your program must implement a hierarchy of packages, with the Package class as the base class and Box, Can, and Sack classes as its derived classes. Be sure to make proper use of inheritance in your hierarchy.
Boxes
A box has the following attributes: length, width, height (all in inches), weight (in pounds), its contents (a string), and the name of the person or place of business to which it is addressed. A box is uniquely identified by all of its attributes.
Cans
A can has the following attributes: its diameter and height (both in inches), weight (in pounds), its contents (a string), and the name of the person or place of business to which it is addressed. A can is uniquely identified by all of its attributes.
Sacks
A sack has the following attributes: its contents (a string), the material from which it is made (a string), weight (in pounds), and the name of the person or place of business to which it is addressed. A sack is uniquely identified by all of its attributes.
At a minimum, your project must detect the following invalid conditions and throw appropriate exceptions. You must create your own exception classes to deal with these conditions.
A command file has the following format. Blank lines may appear anywhere in the file and should be ignored. Any non-blank line may be assumed to be properly formatted and all data may be assumed to be valid. All dimensions (height, width, etc.) are in inches. All weights are given in pounds. A small sample command file is available.
The attributes of the BOX for the LOAD and DELIVER commands are separated by
white space and occur in the following order:
contents (a string with no spaces), length, width, height, weight, and the
name of the person or place of business to which the box should be delivered
(a string that may contain spaces).
The attributes of the SACK for the LOAD and DELIVER commands are separated by
white space and occur in the following order:
contents (a string with no spaces), material (a string with no spaces),
weight, and the name of person or place of business to which the box should
be delivered (a string that may contain spaces).
The attributes of the CAN for the LOAD and DELIVER commands are separated by
white space and occur in the following order:
contents (a string with no spaces), diameter, height, weight, and the
name of the person or place of business to which the box should be delivered
(a string that may contain spaces).
Your program must produce the following outputs displayed to the screen and also written to the text file specified on the command line.
main
.This project is considered an CLOSED project. Please review the CLOSED project policy on the course website.
See the course website for a description of how your project will be graded.
.java
files necessary to compile and run your project.You can check to see what files you have submitted by typing
Remember -- if you make any change to your program, no matter how insignificant it may seem, you should recompile and retest your program before submitting it. Even the smallest typo can cause compiler errors and a reduction in your grade.
Avoid unpleasant surprises!