Again we move to more new concepts to incorporate into a new
project - arrays, classes, files and exceptions (though I've written
the code that incorporates these last two items) . This project continues to feature elements from
prior projects including loops and supporting classes. The main
program should be in Proj5.java (which I have given to you) and the supporting
classes are Airport.java, Airplane.java, and
Seat.java. This project attempts to bring together everything we've
learned up to this point into one big (read many key strokes) project,
so plan accordingly.
Now working from the inside out, these are the classes you will need:
Seat.java
This class contains methods needed to handle information about a seat. There are
three instance variables: occupant, whichClass, and smoking.
The methods you must implement include:
Airplane.java
This class is the workhorse for this project. There are 7 instance variables:
a 2-dimensional array of seats (un-instantiated), the flight number of the
flight, the destination, the number of rows and seats/row, the number of first
class rows, and the number of non-smoking rows.
The methods should include but are not limited to:
Airport.java
This class contains an array of planes and a count of how many there
are as instance variables. I've also included a String with the
airport name as a public constant. Some of the methods needed are:
String
containing a list of the flight numbers and destinations (call Airplane's
toString() in a loop).
String that contains a list of all the passengers on this flight
(should call Airplane's printManifest()). It must first find the flight in
the list. If it's not there an error message should print.
Proj5.java
This is the driver program which starts by declaring the Airport variable. The method to read in the flight information should be called. Then in a do/while loop print the following menu, allow the user to enter a choice, if the choice is not a Q or a L then it should request a flight number, and then in a switch statement, it should execute that choice. The menu should look something like:
----------------------------------------- *** Main Airport Menu *** L) List the flight numbers I) Get Airplane flight inforamtion A) Add passengers to a flight O) Print occupancy chart for a flight M) Print a manifest for a flight Q) Quit Please enter choice->If 'L' is chosen, print out the airport information - the list of flights.
If 'I' is chosen, print out information about a particular flight
If 'A' is chosen, you should call the addPassengers method in Airport passing it the flight number. If the flight exists, call Airplane's addPassengers method to get the passenger information and book the passenger on the flight.
If 'O' is chosen, the program should print an occupancy chart for this particular flight number if it exists.
If 'M' is chosen, the program should print a flight manifest for the particular flight number if it exists.
If 'Q' is chosen the program should quit with a Thank You message.
Be sure your switch statement handles an incorrect choice.
Proj5.java, Airport.java, Airplane.java,and Seat.java.
6 flights read.
*** Main Aiport Menu ***
L) List the flight numbers.
I) Get Airplane flight information.
A) Add passengers to a flight.
O) Print Occupancy Chart for a flight.
M) Print Manifest for a flight.
Q) Quit.
Enter choice -> l
l
William and Mary Regional Airport
UA312 Dinnehotso
Delta222 Kayente
USAir413 Cleveland
TA414 Atlanta
UA110 New York
PanAm15 Chinle
*** Main Aiport Menu ***
L) List the flight numbers.
I) Get Airplane flight information.
A) Add passengers to a flight.
O) Print Occupancy Chart for a flight.
M) Print Manifest for a flight.
Q) Quit.
Enter choice -> i
i
Enter the flight number -> UA312
UA312
Information on flight UA312
Destination: Dinnehotso
Number of rows: 13
Number of seats across: 6
Rows in First Class: 2
Non-smoking rows: 7
*** Main Aiport Menu ***
L) List the flight numbers.
I) Get Airplane flight information.
A) Add passengers to a flight.
O) Print Occupancy Chart for a flight.
M) Print Manifest for a flight.
Q) Quit.
Enter choice -> o
o
Enter the flight number -> UA312
UA312
Flight UA312 to Dinnehotso
A B C D E F
Row 1 FN FN FN FN FN FN
Row 2 FN FN FN FN FN FN
Row 3 EN EN EN EN EN EN
Row 4 EN EN EN EN EN EN
Row 5 EN EN EN EN EN EN
Row 6 EN EN EN EN EN EN
Row 7 EN EN EN EN EN EN
Row 8 ES ES ES ES ES ES
Row 9 ES ES ES ES ES ES
Row 10 ES ES ES ES ES ES
Row 11 ES ES ES ES ES ES
Row 12 ES ES ES ES ES ES
Row 13 ES ES ES ES ES ES
*** Main Aiport Menu ***
L) List the flight numbers.
I) Get Airplane flight information.
A) Add passengers to a flight.
O) Print Occupancy Chart for a flight.
M) Print Manifest for a flight.
Q) Quit.
Enter choice -> a
a
Enter the flight number -> UA312
UA312
Enter the name of the new passenger-> Fred Flintstone
Fred Flintstone
Enter the ticket type (E or F)-> e
E
Enter smoking or non (S or N)-> s
S
Enter desired row-> 9
9
Enter desired seat-> a
A
Fred Flintstone seated on flight UA312 in seat 9A
*** Main Aiport Menu ***
L) List the flight numbers.
I) Get Airplane flight information.
A) Add passengers to a flight.
O) Print Occupancy Chart for a flight.
M) Print Manifest for a flight.
Q) Quit.
Enter choice -> a
a
Enter the flight number -> UA312
UA312
Enter the name of the new passenger-> Barney Rubble
Barney Rubble
Enter the ticket type (E or F)-> f
F
Enter desired row-> 1
1
Enter desired seat-> c
C
Barney Rubble seated on flight UA312 in seat 1C
*** Main Aiport Menu ***
L) List the flight numbers.
I) Get Airplane flight information.
A) Add passengers to a flight.
O) Print Occupancy Chart for a flight.
M) Print Manifest for a flight.
Q) Quit.
Enter choice -> a
a
Enter the flight number -> UA312
UA312
Enter the name of the new passenger-> Sam Spade
Sam Spade
Enter the ticket type (E or F)-> e
E
Enter smoking or non (S or N)-> n
N
Enter desired row-> 6
6
Enter desired seat-> f
F
Sam Spade seated on flight UA312 in seat 6F
*** Main Aiport Menu ***
L) List the flight numbers.
I) Get Airplane flight information.
A) Add passengers to a flight.
O) Print Occupancy Chart for a flight.
M) Print Manifest for a flight.
Q) Quit.
Enter choice -> m
m
Enter the flight number -> UA312
UA312
Manifest for flight UA312 to Dinnehotso
1C Barney Rubble
6F Sam Spade
9A Fred Flintstone
*** Main Aiport Menu ***
L) List the flight numbers.
I) Get Airplane flight information.
A) Add passengers to a flight.
O) Print Occupancy Chart for a flight.
M) Print Manifest for a flight.
Q) Quit.
Enter choice -> a
a
Enter the flight number -> UA312
UA312
Enter the name of the new passenger-> George Jetson
George Jetson
Enter the ticket type (E or F)-> f
F
Enter desired row-> 2
2
Enter desired seat-> a
A
George Jetson seated on flight UA312 in seat 2A
*** Main Aiport Menu ***
L) List the flight numbers.
I) Get Airplane flight information.
A) Add passengers to a flight.
O) Print Occupancy Chart for a flight.
M) Print Manifest for a flight.
Q) Quit.
Enter choice -> a
a
Enter the flight number -> UA312
UA312
Enter the name of the new passenger-> bad guy
bad guy
Enter the ticket type (E or F)-> e
E
Enter smoking or non (S or N)-> n
N
Enter desired row-> 2
2
Enter desired seat-> b
B
This seat is not available or does not fit the passenger's criteria or is not a valid seat.
Would you like to reenter data (R) or Exit(E)-> r
r
Enter the ticket type (E or F)-> e
E
Enter smoking or non (S or N)-> n
N
Enter desired row-> 10
10
Enter desired seat-> c
C
This seat is not available or does not fit the passenger's criteria or is not a valid seat.
Would you like to reenter data (R) or Exit(E)-> r
r
Enter the ticket type (E or F)-> e
E
Enter smoking or non (S or N)-> s
S
Enter desired row-> 10
10
Enter desired seat-> c
C
bad guy seated on flight UA312 in seat 10C
*** Main Aiport Menu ***
L) List the flight numbers.
I) Get Airplane flight information.
A) Add passengers to a flight.
O) Print Occupancy Chart for a flight.
M) Print Manifest for a flight.
Q) Quit.
Enter choice -> o
o
Enter the flight number -> UA312
UA312
Flight UA312 to Dinnehotso
A B C D E F
Row 1 FN FN X FN FN FN
Row 2 X FN FN FN FN FN
Row 3 EN EN EN EN EN EN
Row 4 EN EN EN EN EN EN
Row 5 EN EN EN EN EN EN
Row 6 EN EN EN EN EN X
Row 7 EN EN EN EN EN EN
Row 8 ES ES ES ES ES ES
Row 9 X ES ES ES ES ES
Row 10 ES ES X ES ES ES
Row 11 ES ES ES ES ES ES
Row 12 ES ES ES ES ES ES
Row 13 ES ES ES ES ES ES
*** Main Aiport Menu ***
L) List the flight numbers.
I) Get Airplane flight information.
A) Add passengers to a flight.
O) Print Occupancy Chart for a flight.
M) Print Manifest for a flight.
Q) Quit.
Enter choice -> a
a
Enter the flight number -> UA312
UA312
Enter the name of the new passenger-> Joe Bloe
Joe Bloe
Enter the ticket type (E or F)-> f
F
Enter desired row-> 2
2
Enter desired seat-> a
A
This seat is not available or does not fit the passenger's criteria or is not a valid seat.
Would you like to reenter data (R) or Exit(E)-> e
e
*** Main Aiport Menu ***
L) List the flight numbers.
I) Get Airplane flight information.
A) Add passengers to a flight.
O) Print Occupancy Chart for a flight.
M) Print Manifest for a flight.
Q) Quit.
Enter choice -> m
m
Enter the flight number -> UA312
UA312
Manifest for flight UA312 to Dinnehotso
1C Barney Rubble
2A George Jetson
6F Sam Spade
9A Fred Flintstone
10C bad guy
*** Main Aiport Menu ***
L) List the flight numbers.
I) Get Airplane flight information.
A) Add passengers to a flight.
O) Print Occupancy Chart for a flight.
M) Print Manifest for a flight.
Q) Quit.
Enter choice -> l
l
William and Mary Regional Airport
UA312 Dinnehotso
Delta222 Kayente
USAir413 Cleveland
TA414 Atlanta
UA110 New York
PanAm15 Chinle
*** Main Aiport Menu ***
L) List the flight numbers.
I) Get Airplane flight information.
A) Add passengers to a flight.
O) Print Occupancy Chart for a flight.
M) Print Manifest for a flight.
Q) Quit.
Enter choice -> o
o
Enter the flight number -> PanAm15
PanAm15
Flight PanAm15 to Chinle
A B C D E F G H I J
Row 1 FN FN FN FN FN FN FN FN FN FN
Row 2 FN FN FN FN FN FN FN FN FN FN
Row 3 FN FN FN FN FN FN FN FN FN FN
Row 4 FN FN FN FN FN FN FN FN FN FN
Row 5 FN FN FN FN FN FN FN FN FN FN
Row 6 FN FN FN FN FN FN FN FN FN FN
Row 7 EN EN EN EN EN EN EN EN EN EN
Row 8 EN EN EN EN EN EN EN EN EN EN
Row 9 EN EN EN EN EN EN EN EN EN EN
Row 10 EN EN EN EN EN EN EN EN EN EN
Row 11 EN EN EN EN EN EN EN EN EN EN
Row 12 EN EN EN EN EN EN EN EN EN EN
Row 13 EN EN EN EN EN EN EN EN EN EN
Row 14 EN EN EN EN EN EN EN EN EN EN
Row 15 EN EN EN EN EN EN EN EN EN EN
Row 16 ES ES ES ES ES ES ES ES ES ES
Row 17 ES ES ES ES ES ES ES ES ES ES
Row 18 ES ES ES ES ES ES ES ES ES ES
Row 19 ES ES ES ES ES ES ES ES ES ES
Row 20 ES ES ES ES ES ES ES ES ES ES
*** Main Aiport Menu ***
L) List the flight numbers.
I) Get Airplane flight information.
A) Add passengers to a flight.
O) Print Occupancy Chart for a flight.
M) Print Manifest for a flight.
Q) Quit.
Enter choice -> k
k
You've entered an invalid choice.
*** Main Aiport Menu ***
L) List the flight numbers.
I) Get Airplane flight information.
A) Add passengers to a flight.
O) Print Occupancy Chart for a flight.
M) Print Manifest for a flight.
Q) Quit.
Enter choice -> q
q
Thank you for using the Flight reservation program.
With the help
of the Style Guide in your Lab manual, fully document your code
following the javadoc conventions and include:
} // main
Information needed for testing this program are linked from the top of the page and can be imported (see below). Test your program thorougly with the data and sample output given before submitting.
Submit your program file electronically. In Eclipse, right click on the project and import the files from /home/f85/debbie/cs141/Proj5. This will include the airplanes.txt file, testa.dat, and Proj5.java.
Right click on the file submit.xml and select Run -< 1 Ant Build;. Messages will appear in the Console window. Be sure to determine whether you got the Build successful message to ensure that your electronic file submission for this program was successful.
Honor Code. The honor code applies to all programming done in this course. Reread the CS Department's document: Programming Assignments and the Honor Code.