Due: 1/28/00
The purpose of this first assignment is to give you practice working with classes and arrays. The notes in the blue book should be helpful, but some additional programming will be required.
A very small rural post office (the population of the community is 20) offers three different types of post office boxes: an 4 X 8 inch box, an 8 X 8 inch box and an 8 X 16 inch box. There are a maximum number available of each size box. The max for 4 X 8 is 10, for 8 X 8 is 7 and for 8 X 16 is 5. You are to set up a class for the post office box which has length, width, box number (1 - 10 for 4 X 8, 11 - 18 for 8 X 8, and 19 - 23 for 8 X 16), and name of box holder as instance variables. The post office will be an array of post office boxes. You must keep track of how many of each type of box is occupied and give the client the methods addBox, deleteBox, and displayDetails. Your client class (PostOffice) will contain a main( ) method which will prompt the user for action to be performed (add, del, display) and the choice of box size.
You will need to display an error message to the user if there are no more boxes of the selected size available. The user must choose between one of the three sizes.
Have your main method perform the following in order:
Add the following boxes:
1) 8 X 16
for Mary Crumb
2) 4 X 8
Dexter Pagdilao
3) 8 X 16
Tony Smith
4) 8 X 16
Debbie Mosser
5) 8 X 16
Diane Reilly
6) 8 X 16
Pam Palmer
7) 8 X 8
Doby Gillis
Now delete the box for Diane Reilly
Add an 8 X 16 box for Molly Morris
Display details of the post office
Classes:
PostOfficeBox
Instance variables: int width int length int boxNumber String nameOfOwner Constructors: PostOfficeBox ( ) Instance Methods: toString( )PostOffice
Class variables: final int max4X8 final int max8X8 final int max8X16 Instance variables: PostOfficeBox [ ] theBoxes int lastInUse Constructors: PostOffice ( ) Instance Methods: addBox( ) deleteBox( ) displayPOBoxes( )Supply methods and variables to support the above as needed.
Output: Example of detailed report:
Box Number Box size Name of owner
1 4 X 8 Alice Smith
11 8 X 8 John Doe
19 8 X 16 Sally Jones
Documentation:
Submit in a two-pocket folder with label on cover containing your name and section and date submitted. In the left pocket should be a hard copy of the documented source code, and a hard copy of output. Your documentation should model the USA.java file on the shared drive in the lab. In the right pocket clip your labeled disk containing your class and java files. Your disk must contain all of the necessary files to run your program.