The following skills are addressed in completing this
assignment.
- Writing java code to create an attractive user interface
- Creating and using your own classes
- Using selection structures
- Using repetition structures
- Validating user input
- Using a simple array of objects
- Decomposing a complex problem in a top-down fashion
- Following a “style guide”
- READING AND FOLLOWING DIRECTIONS!!!!!
Background
Dukes Shipping provides package shipping services of a specialized
nature. The will only ship containers that are already in
boxes and they provide outer protective boxes and packing material to
protect those contents. Dukes Shipping maintains a warehouse
of boxes in which to ship the customer's package. When a customer comes
in, the clerk must measure the customer's box and then decide whether
or not there is a box into which the customer's box can be placed.
If so, we can ship the package. If not, we must
turn the customer away. It is important that we
match the boxes to the customer's box as closely as we can. If we waste a
large container with a small box we potentially could lose a sale.
This application will help the sales clerk to find the
shipping box with the best fit to the customer's box.
This program is a "choose your own grade" program. The easiest
version (version 1) uses a warehouse that has an unlimited supply of 3
standard (constant) shipping boxes. The 2nd version has a
warehouse with an unlimited supply of up to 20 different sized
containers that are entered in by a user and stored as an array of Box
objects. Finally, the 3rd (and hardest) version has a warehouse
that has 20 different containers that are removed from the warehouse
when used for shipping. Versions 2 and 3 then will require
you to manage the inventory in the warehouse. All three versions
will require you to find the shipping box that best fits the package to
be shipped.
The three versions are defined below.
General Specification
In this assignment, you will design and implement a program
that populates a Warehouse
with Box
es
and and that allows individual Box
es to be
shipped. Your program must be built using the following four classes:
Each Box
is identified by its dimensions
(length, width, and depth). In order to ship a box, you must get its
dimensions to determine which box in the Warehouse
is the
"best" box in which to ship it. The "best" box is the box with the
smallest volume that is large enough to contain the box to be sent.
Displaying boxes
Displaying boxes - All options and parts
Anytime you must display a
box, you will use the string "lengthxwidthxdepth"
where length, width, and depth are the size dimensions of the
box, formatted to two decimal positions.
Error messages for box dimensions
Anytime that we are providing dimensions for boxes, the values must be
positive non-zero values. If a value is wrong, you should
echo
the bad value with the line, "You
entered badValue.
You must enter a number that is greater than zero."
followed by the
newline character followed by the prompt for the value that was bad.
You should display the error message as soon as it is entered.
Part 1 - Specifications
User interface - Part 1 - Menu
You should present a
welcome message to the user and a menu.
The welcome should read:
Welcome to Dukes
Shipping Service
This
welcome should be followed by a blank line.
What do you want to
do?
2. Ship box from warehouse
3. Quit
Each time the user chooses
an option,
the menu should carry out the action and return to the menu, printing
the entire menu again.
You must validate the menu choices and present an error message, "Your choice badValue is invalid, please try
again" followed by a blank line and followed by a refresh
of the menu. badValue
should be replaced by the user's entry.
User interface - Version 1 Options
Option 2 - Ship box from warehouse
After this choice is made, the application must display a message, "What is the size of your
box?" followed by the newline, followed by the word
"Length: ". You should read and validate the
length, then print the
newline character and the word
"Width: ". Read in and validate the
width and then print a newline character and the word "Depth: "
Again
read and validate the value and print the new line character.
See
below for error message requirements.
After getting the size of
the box to ship, the application should display one of two messages,
either :
If a suitable box is not found:
For the box 20x10x12:
No shipping box found.
If a suitable box is found:
For the box 10x7x12:
Use box: 15x20x8.
Option 3
- Quit
You should exit the
program with the statement "Dukes
Shipping Service ending." followed by the newline
character.
Version 2 - Specifications
User interface - Version 2 - Menu
You should present a welcome message to the user and a menu.
The welcome should read:
Welcome to Dukes
Shipping Service
This
welcome should be followed by a blank line.
What do you want to
do?
1. Add box to warehouse
2. Ship box from warehouse
3. Quit
Each time the user chooses
an option,
the menu should carry out the action and return to the menu, printing
the entire menu again.
You must validate the menu choices and present an error message, "Your choice badValue is invalid, please try
again" followed by a blank line and followed by a refresh
of the menu. badValue
should be replaced by the user's entry.
After getting the size of
the box to ship, the application should display one of two messages,
either :
If a suitable box is not found:
For the box 20x10x12:
No shipping box found.
If a suitable box is found:
For the box 10x7x12:
Box 14: 12x10x15. (In this case 14 is
the "slot" number in which that box will be found corresponding to the
array entry.)
User interface -Version 2 and 3 - Each option
Option 1 - Add box to warehouse.
After this choice is made,
the application must display a message, "What is the size of your
box?" followed by the newline, followed by the word
"Length: ". You should read and validate the length, then
print
the newline character and the word "Width: ". Read in and
validate the width and then print a newline character and the word
Depth: " Again read and validate the value and
print the new
line character. See below for error message requirements.
A blank line should follow the size prompts followed by
one of two messages, either
"Box added" or
"Warehouse full, box not added".
Option 2 (all Versions)
- Ship box from warehouse
After this choice is made,
the application must display a message, "What is the size of your
box?" followed by the newline, followed by the word
"Length: ". You should read and validate the
length, then print the
newline character and the word
"Width: ". Read in and validate the
width and then print a newline character and the word "Depth: "
Again
read and validate the value and print the new line character.
See
below for error message requirements.
After getting the size of
the box to ship, the application should display one of two messages,
either :
If a suitable box is not found:
For the box 20x10x12:
No shipping box found.
If a suitable box is found:
For the box 10x7x12:
Box 14: 12x10x15. (In this case 14 is
the "slot" number in which that box will be found corresponding to the
array entry.)
If the warehouse is empty:
Cannot ship.
Warehouse is empty.
Option 3 (all Versions)
- Quit
You should exit the
program with the statement "Dukes
Shipping Service ending." followed by the newline
character.
Additional requirements
In addition to the above, your program must conform to the following
requirements:
- You must use the starter programs provided. You
must use
the headers for the suggested methods in Box and Warehouse.
You
may add additional methods and you may add additional classes.
Added methods should be private unless they are providing a service to
the outside classes.
- The
Warehouse
- for Version 1 - should store 3 constant boxes which will
represent
a small box, a medium box, and a large box. These are the
only
three that are stocked and we will assume that you have an unlimited
number of such boxes. The small box will be 4 x 6 x 2, a
medium
box will be 10 x 10 x 6 and a large box will be 15 x 20 x 8.
- for Version 2 - should store the
individual
Box
es in an array in the Warehouse.
Your
array must be of size 20. Boxes may be "reused" or in other
words, using a box from the warehouse does not remove the box from the
warehouse.
- for Version 3 - you should actually remove the box from the
array when it is used so that it cannot be reused.
- When a
Box
is added to the Warehouse
,
it should be added to the end of the array.
- If the
Warehouse
is full (the the
array has no more slots), you should notify the user that the warehouse
is full with the message listed above.
- If no suitable
Box
is found, your
program should output the following:
For the box 10x7x12:
No shipping box found.
- If a suitable box is found, the output should look like
this:
For the box 10x7x12:
Box 14: 12x10x15. (In this case 14 is
the "slot" number in which that box will be found corresponding to the
array entry.)
- All input should be validated. This includes both the menu
(only 1 - 3) and the box dimensions (only positive numbers allowed).
- You must write the methods as specified in each of the
provided java files (
Box.java
and Warehouse.java
).
You will need to design the BestBox.java
yourself.
- All I/O (
Scanner
or Keyboard
objects and System.out.print...
) should occur
in BestBox.java
(unless you use a new class for that purpose only).
Hints and
Notes:
- The box to
be sent fits inside a shipping box if each of the
dimensions of the box to be sent are smaller than (not the same as) the
shipping box's dimension.
- The BestBox should use an
algorithm that includes the dimensions and volume of the box in determining which container to use. We
want the box with the smallest volume that will fit the box to be
shipped.
- The box may
be turned in any
direction. Do not assume that it matters which dimension is
entered first second or third. In other words, a box of size
10x8x6 is the same as a box of 8x6x10.
- If you do Version 1 first, you
will only need to change the Warehouse class....the Box, Boxes, and
BestBox classes should remain the same. You might use the simple
WarehouseV1 class as your tester for the BestBox methods before you try
to tackle the Warehouse class for Version 2 and 3.
Grading:
Completing Version 1 will acheive 55 points toward the total assignment
score. (C)
Completing Version 2 will acheive 70 points toward the total assignment
score. (B)
Completing Version 3 will acheive 80 points toward the total assignment
score. (A)
In addition, 20 points will be awarded for conformance to the Style
Guide for your class.