Question
Flying . . . with Reservations You are to write a program to set up and maintain the list of flight information of a small
Flying . . . with Reservations
You are to write a program to set up and maintain the list of flight information of a small airline company. City Shuttle has two scheduled flights per day: Flight 598 and Flight 604. For each of these flights, City Shuttle would like to maintain a list of passenger reservations, in alphabetic order by passenger name (sorted list?). The program should, among other things, be able to add a passenger to a flight if there is space on it, cancel a passengers reservation, or implement a passengers decision to change flights.
This program will be completed in fairly short order.
INPUT
The input text file, flight.txt, will consist of the following commands, where
RESERVE
CANCEL
FIND
CHANGE
do not delete
LIST
STOP Terminate execution
Input is free format. That is, an arbitrary number of blank spaces and end-of-lines may occur between any two input commands. In each command, only one blank space will be used to separate a parameter from its command.
OUTPUT
Output will sent to the external file flightlog.txt. (For testing purposes, you can also send output to the terminal window.) Echoprint each command. Then follow each command with an appropriate message indicating the action taken. The action of the LIST command is self-evident.
ERRORS
The following logical errors are possible and should be handled by printing appropriate error messages:
1. Trying to add a new passenger to the flight when it is full.
2. Trying to delete a nonexistent passenger from the flight.
3. Trying to add a passenger to the flight more than once.
4. Trying to reference a nonexistent flight.
ASSUMPTIONS
1. You may assume that the input data are syntactically correct (i.e., no nonexistent commands).
2. For simplicity, only surnames will be used.
3. The flight has seats for a maximum of 10 passengers.
REQUIREMENTS
The passenger list for the flight should be represented as separate key-ordered list objects. The required information for the flight object might look similar to the following.
FLIGHT598 |
|
|
|
| . . . . |
|
|
Since we have data structures that will do a lot of the work for us, we will focus on good design and modularity. Dont be in a rush to start coding. There is a lot of design work to be done. Your best resources for help are attending class, and your instructor. Your expert coding friends wont know the application or particular coding constraints and conventions used in this class.
You may use the texts List implementation, or Javas LinkedList class (import java.util.LinkedList;). The text List code contains an ordered (or sorted) list. The Java utility does not maintain a list in sorted order.
LIST 598 RESERVE 598 Simpson RESERVE 604 Martin RESERVE 604 Harris RESERVE 598 Reynolds LIST 598 RESERVE 598 Garrity RESERVE 604 King RESERVE 598 Edwards RESERVE 598 Parker LIST 604 RESERVE 604 McGonegall FIND 598 Garrison RESERVE 598 Jones FIND 598 Garrison RESERVE 598 Smith RESERVE 598 Jones RESERVE 598 Adams CHANGE 598 604 Reynolds RESERVE 598 Leonard RESERVE 598 Molson CANCEL 598 Reynolds RESERVE 598 Molson LIST 598 LIST 589 LIST 604 RESERVE 598 Gordon CHANGE 604 598 Adams CHANGE 598 604 Parker RESERVE 598 Rawlins RESERVE 598 Pollard LIST 598 FIND 598 Korngold FIND 598 Jones RESERVE 598 Yates RESERVE 598 Woolsey RESERVE 598 Huston CANCEL 598 Rawlins LIST 598 LIST 598 RESERVE 598 Delius RESERVE 598 Carlson RESERVE 598 Ardworth RESERVE 598 Thomas RESERVE 598 Norris RESERVE 598 Morris CHANGE 598 604 Norris RESERVE 598 Ulrich RESERVE 598 Harding CANCEL 598 Delius FIND 598 Morris CANCEL 598 Ardworth FIND 598 McTaggart RESERVE 598 Carlson LIST 598 LIST 604 STOP
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started