CMSC 202 Project 5

Transport Aircraft

Assigned Monday Nov 24, 2008
Program Due 7:00AM, Wednesday Dec 10, 2008
Weight 10%
Updates  

Objectives


Project Description
A transport aircraft carries "things" like cargo, people, and water from one destination to another. Transport aircraft have the same basic behaviors -- take off, landing, loading, unloading, etc., -- regardless of what kind of "thing" it is carrying. Because all transport aircraft have the same behavior, it is appropriate to design and implement a generic transport aircraft class. In this project, the generic transport aircraft will be used as both a cargo plane and a commuter plane.

In this project you will use text file I/O to read commands from a file. These commands will tell your transport aicraft what functions to perform. Output will be written to a logfile.

You will also be designing and using your own exception classes. The conditions under which an exception is thrown are listed in the details below.

Project 5 is invoked with the following command line arguments in the order listed here.

  1. the type of transport will be flown -- "cargo" or "commuter" (without the quotes)
  2. the name of the transport's city of origin
  3. the transport's minimum flying altitude
  4. the transport's maximum flying altitude
  5. the maximum number of items the transport can hold (regardless of any attributes)
  6. the name of the command file
  7. the name of the file to which command output and error messages are logged
You may assume that the command line arguments are of the apporpriate type, integers are positive, and that the flying altitudes are consistent (i.e. max >= min).

Your Tasks

  1. Read the description of the command file and the requirements section below.
  2. Based on those descriptions design and implement a generic class to model the transport aircraft.
  3. Based on those descriptions design and implement a class to model cargo.
  4. Based on those descriptions design and implement a class to model a person.
  5. Write main( ) and all its helper methods in a class named Project5.java.
  6. Design, implement, and appropriately use exception classes to detect and handle error conditions.
  7. Design and implement any other classes you feel are necessary.
The Command File
For this project, the orders for each aircraft will be read from a file, the name of which is a command line argument. Each command and each data item will be on a separate line in the command file. The format of the PRINT, LAND, TAKEOFF, CLIMB, DESCEND and QUIT commands are identical for all transport aircraft. The format of LOAD and UNLOAD are different for each type of transport aircraft. City names, person names, and unique cargo labels may be multi-word strings. Commands and unique government-issued IDs do not contain spaces.
  1. PRINT -- Outputs the following information to the log file.
    1. the aircraft's min and max flying altitudes
    2. the maximum number of items the aircraft can hold
    3. the aircrafts current position (ie. flying from HERE to THERE, on the ground in CITY)
    4. details of each "thing" being transported, or an apporpriate message that the aircraft is empty
      • Cargo items are listed in sorted order by their unique label. All attributes of the cargo item must be listed on the same line.
      • People are listed in sorted order by their unique government-issued ID. All attributes of the person must be listed on the same line.
  2. LAND -- the aircraft reaches its destination and is parked, ready for loading or unloading
    The contents of the aircraft are NOT unloaded.
  3. QUIT -- indicates the end of the command file. Your program exits gracefully.
  4. TAKEOFF <city> -- the aircraft begins flying to the specified destination at its minumum flying altitude.
  5. CLIMB <nr of feet> -- the aircraft increases its flying altitude by the specified number of feet. This is NOT the new flying altitude.
  6. DESCEND <nr of feet> -- the aircraft decreases its flying altitude by the specified number of feet. This is NOT the new flying altitude.
  7. The formats for LOAD and UNLOAD are different for each type of "thing" the transport aircraft is carrying

  8. LOAD
      aircraft carrying cargo: LOAD <unique cargo label> <weight> <height> <width> <length>
      where the label is a string, and the other attributes are integers. The unit of measure for weight, height, width, and length is irrelevant.
    1. aircraft carrying people : LOAD <Person name> <age> <Unique government issued ID>
      where the name and ID are strings, and the age is a reasonable positive integer.
  9. UNLOAD
    1. aircraft carrying cargo: UNLOAD <unique cargo label>
    2. aircraft carrying people: UNLOAD <unique government issued ID>
The Logfile File
All required output and error messages from aircraft commands must be written to a logfile using text file I/O. The name of the logfile is a command line argument. The required output is described in the command file section above.
Exception Conditions
Your code must handle the following exception conditions. Any other error conditions that your code introduces should also be checked. Be sure to use appropriate exceptions together with try/catch blocks to separate error detection from error handling.
  1. If there are any errors with the command line arguments, display an appropriate error message to the screen or log an error to the logfile and exit your program. You should check that the number of command line arguments is correct and that each of the files can be opened appropriately. (Of course if the error is that the logfile can't be opened then the error should be printed to System.out)
  2. If an attempt is made to load an item onto a full transport aircraft, log an appropriate message and continue to the next command in the file.
  3. If transport aircraft is commanded to climb too high, log an appropriate error message, level off at the maximum flying altitude, and continue to the next command in the file
  4. If transport aircraft is commanded to decsend too low, log an appropriate error message, level off at the minumum flying altitude, and continue to the next command in the file
  5. If an attempt is made to unload a non-existent "thing", log an appropriate message and continue to the next command in the file.
  6. If the transport aircraft is commanded to do something that makes no logical sense given its current state, the command should be disregarded (but still logged), an error message should be logged, and the next command read from the file.

Requirements, Restrictions, and Assumptions

  1. Mr. Frey's public directory for this project is /afs/umbc.edu/users/f/r/frey/pub/202/Proj5.
  2. A sample command file is available in Mr. Frey's public directory.
  3. There are NO weight or volume restrictions when loading "things". The only restriction is on the number of items loaded
  4. "things" do NOT automatically unload when the transport lands.
  5. You may assume that all command file data is valid. In particular this means
    1. The format of the command file will be valid as specified above
    2. The values of all data in the command file will be valid (eg positive)
    3. The command file will contain no invalid commands
    It DOES NOT mean that all commands make common sense or are valid commands. See Exception Conditions above.
  6. All commands and their parameters must be logged to the logfile as they are being executed, even if the command is not actually carried out.
  7. Appropriate object-oriented design is required. As discussed in class throughout the semester, this includes, but is not limited to
    1. private instance variables only
    2. limited public interfaces for all class - don't write unnecessary methods
    3. maximum code reuse
    4. use of try-throw-catch for expections
  8. Appropriate top-down design for main( ) and its helper methods is required.
  9. Sanity Check: How much code in your transport aircraft class, cargo class, and person class would have to change if a third kind of "thing" to be carried (say barrels of oil) were added to this project? If the answer isn't "NONE!!" then you're doing something wrong.

Project Policy
This project is considered an CLOSED project. This means
  1. You should try as much as possible to complete the project by yourself.
  2. You may get assistance only from the TAs or instructors
  3. You must document all outside help you get as part of your file header comment.
As usual, you MAY NOT
  1. copy anyone else's code
  2. have someone else write your code for you
  3. submit someone else's code as your own
  4. look at someone else's code
  5. have someone else's code in your possession at any time
Such offenses are violations of the student code of academic conduct.
Grading
See the course website for a description of how your project will be graded.
Project Submission
The order in which the files are submitted doesn't matter. However, you must make sure that all files necessary to compile your project are listed. You need not submit all files at the same time. You may resubmit your files as often as you like, but only the last submittal will be graded and will be used to determine if your project is late. For more information, see the projects page on the course website.

You can check to see what files you have submitted by typing

submitls cs202 Proj5

More complete documentation for submit and related commands can be found here.

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!