Assignment 2
CSC 115, Fall 2002

Objectives:

Note:  The assignment will be marked out 100 marks -- Part A is worth 15 marks, Part B is worth 85 marks.  The assignment is worth 5% of your final grade.  Due dates for Parts A and B are provided below.

Problem:

You have been approached by a client who operates a small no-frills (i.e. low-cost) airline and has asked you for a very simple computer system that will eventually form the basis for a larger working system.  A programmer has already spent some time designing the main structure of the program and in fact has even implemented some of the code.  Unfortunately, this programmer left the company rather suddenly without even documenting their code!   As a first task, you need to understand the existing code that has been written and provide documentation for those classes.  Next you will need to implement some more of the code required for the airline passenger system.    The following lists the functional requirements of the system.

 

Functional requirements:

 

The client wants the system to keep track of the following information for each flight:


The client wants to be able to perform the following actions with the airline system for each flight:


Instructions:

Part A

The previous programmer did some work for you already but before you can start writing code you first have to understand what has been done.    You have been provided with the following classes:

Unfortunately, the files provided have not been documented.  Your first task is to add inline comments and Javadoc comments to each of these files.  Furthermore, to help you understand the general scope of the program and the design of the various classes, you need to draw a picture of how the different classes will be used in the software system.  You do not need to use any particular notation for your diagram, but do provide a legend for your drawing so that others can interpret it. 

Deliverables and due date for Part A: 

Part A is due at the end of your lab during the week of October 14th (you must attend the lab you are registered for).

 

You need to start Part A before the lab, but you may finish it in the lab and ask questions as required.  Furthermore, you should also have spent some time thinking about Part B so that you can ask more pertinent questions during this lab.

 

For Part A, hand in printouts of the commented code, with your name, lab section, and student number in the header comments.  Also hand in your diagram (a neatly hand drawn diagram is acceptable). 

 

Hints: 

  1. You should start Part A before your lab.  In particular you should draw the diagram and read the source code provided in advance of the lab. 
  2. A better understanding of what is required for Part B will help you do the documentation and with drawing a diagram so you should read Part B before doing Part A. 
  3. The javadoc commenting style is to be also used for the code we provide. These are the comments that define the purpose, input, and expected output of each of your public methods and classes.
  4. The regular comments must contain instructions for programmers who may have to modify your code at some later date. These comments should help the programmer understand what the code is doing in plain language. You can assume that the programmer is experienced enough to know what while loops and if-statements are.

Part B

Now that you have a better understanding of the code provided, as well as insight about the general design and requirements for the program, you need to do some more of the implementation.    The following lists the main things you need to do.

  1. You need to implement the TravellerList class.  Objects of this class will keep track of the flight travellers (passengers and infants) for a particular flight.  The general structure of the TravellerList class has already been specified by the TravellerListUtils interface (see TravellerListUtils.java).  
     
  2. Implement the Flight class as specified by the FlightUtils interface (see FlightUtils.java).   Recall from above that the Flight class needs to keep track of the flight number, the miles to travel, the number of seats on the plane, as well as the list of travellers.  The Flight class is also responsible for checking in passengers and infants, and assigning seats and meals.  Furthermore, the Flight class needs to provide several methods for printing lists of the travellers on the plane (see the FlightUtils.java file and the above description of the functional requirements for details on the required methods).   Note, your program does not (at this time) need to provide a user interface for getting details on passengers and infants.  You should hardcode the passengers, elite passengers and infants in your Tester class (see item #5 below).
     
  3. In order for the Flight class to provide the required printouts of passengers,  you need to add several private inner class Iterators to the TravellerList class.  The first iterator iterates through the traveller list in FIFO (first-in, first-out) order.   The second iterator iterates the list in LIFO (last-in, first-out) order, and the third iterator is a specialized iterator that only iterates through the elite passengers in FIFO order.   
     
  4. The program should handle at least two exceptions:  If the user of the program tries to book a space for an infant that is older than 24 months, the checkinInfant method in the Flight class must throw an InfantTooOldException.  We provide the class for this exception (see InfantTooOldException.java).
    Also, if the user of the program tries to book a seat for a passenger when the plane is full, the checkinPassenger method in the Flight class must throw an OverBookedException.  We also provided the class for this exception (see OverBookedException.java).
      You should catch these exceptions in your Tester class (see next item).
     
  5. We have provided a fairly simple Tester class for testing the program (see Tester.java and output.txt).  You should add more passengers and infants to check in within the main method in this class to test how robust your program is. 

Deliverables and due date for Part B:

 

Part B is due on Tuesday, October 22nd by 6pm.  Submit all commented .java files by electronic submission page BEFORE 6 PM on the 22nd.  You should also electronically submit the commented files from Part A.  Please ensure that your code is submitted before this time, as the submission program will not accept late assignments.  Please also be sure that your submission compiles and runs before you submit these files. Also submit a printout of all your source code, stapled together, in class on the following day --  Wednesday, 23rd October. 

 

Summary of files to implement for Part B:

Remember to submit all documented source files from both Part A and Part B.

Rules and Hints:

  1. You must not alter or vary from the interfaces and specifications provided. 
  2. File headers must contain your name and/or your student number.
  3. The javadoc commenting style is to be also used for the code you added in Part B. These are the comments that define the purpose, input, and expected output of each of your public methods and classes.
  4. The regular comments must contain instructions for programmers who may have to modify your code at some later date. These comments should help the programmer understand what the code is doing in plain language. You can assume that the programmer is intelligent to know what while loops and if-statements are. 
  5. Your program should be robust, unit test each of the classes and test your program carefully for boundary cases and unusual input.  Expand the Tester class accordingly, and expand on the main methods in each of the TravellerList and Flight classes you wrote.  Note that we will use a more detailed Tester class to test your code more thoroughly.
  6. Implement just one iterator first and get it working before attempting the other iterators.   Make liberal use of the toString methods for debugging purposes.

Bonus:

In Tester instead of creating the passengers and infants one at a time, read in the data required for the program from a file.  (Max of 10 bonus marks).


Notice: 

If you find any errors or inconsistencies in this document, report them immediately to csc115@csc.uvic.ca. Notification of changes (or clarifications) will be posted on the CSC115 Forum on WebBoard .