Sem 1 2020
Dr. Seyedjamal Zolhavarieh, Auckland University of Technology, [email protected]
The Airline Reservation System
Due date: Monday, 15th June 2020 at 5:00 pm
This assignment has 100 marks and is worth 20% of your final grade.
Brief

For this assignment, you will individually develop an Airline Reservation  Application in Java, enabling airlines to view the seating map of a flight and to  make seat bookings in first or economy class, based on their policies. For a  given flight, the Airline Reservation Application retrieves its seating map partitioned into first and economy classes, as depicted in the left-hand side of Figure 1. A seat request marks a seat as booked. For example, the first-class  seat 3E is booked and shown on the left-hand side of Figure 1 as a solid circle.  This Seat is an aisle type of Seat since it is next to an aisle. Similarly, window  type seats are next to the airplane's windows (such as 5A), and all other seats  are middle type seats (such as 9D).


Figure 1: Seat map stored as a 2D array of Seat objects
Methodology and Marking Scheme
You will develop several classes in Java that implement the Airline Reservation Application. For full marks, your classes must adhere to correct OOP design principles. You have been provided with an outline of eleven classes which  contain the core functionalities of the Airline Reservation applications: SeatType, SeatPosition, Seat, SeatMap, AirBusSeatMap, BoeingSeatMap,  Flight, Airline, SimpleWay, SmartLine, and AirlineReservationApplication. The   relationships between classes are described below using a UML Class Diagram (Figure 2). Complete the assignment by using the given UML class diagram and  following the below steps to develop the eleven classes with the provided  instance variables and methods with appropriate access modifiers (as shown in  the diagram). Take the time to test your methods as you progress.
Note: You need to provide attributes and methods that are listed in the UML  diagram, even those which are not defined in the step sections. Some of them  are clear, and that is why they have not mentioned in steps. You may also add  more methods if you need.


Figure 2: UML Diagram of The Airline Reservation Application
<>
SeatType
WINDOW
AISLE
MIDDLE
SeatPosition
- row: int
- column: char
+ SeatPosition(int, char)
+ getRow(): int
+ getColumn(): char

Seat
- seatType: SeatType
- firstClass: boolean
- reserved: boolean
- seatPosition: SeatPosition
+ Seat(SeatPosition, SeatType, boolean)
+ getSeatType(): SeatType
+ isFirstClass(): boolean
+ isReserved(): boolean
+ setReserved(boolean)
+ getSeatposition(): SeatPosition
+ toDescription(): String
+ toString(): String
<>
SeatMap
# seats: Seat[][]
# nRows: int
# nColumns: int
# nFirstClassRows: int
# initialiseSeatMap()
+ lastSeatColumn(): char
+ lastSeatRow(): int
+ getLeft(Seat): Seat
+ getRight(Seat): Seat
+ toString(): String
+queryAvailableEconomySeat(SeatType): Seat
+queryAvailableFirstClassSeat(SeatType): Seat
+getSeat(int, char): Seat
+ getSeatsArray(): Seat[][]
+ getNRows(): int
+ getNColumns(): int
+ getNFirstClassRows(): int

BoeingSeatMap AirBusSeatMap
+ BoeingSeatMap()
# initialiseSeatMap()
+ AirBusSeatMap()
# initialiseSeatMap()

Flight
- flightIdentifier: String
- originCity: String
- destCity: String
- departureTime: String
- seating: SeatMap
+ Flight(String, String, String, String, SeatMap)
+ getFlightNumber(): String
+ getOriginCity(): String
+ setOriginCity(String)
+ getDestCity(): String
+ setDestCity(String)
+ getSeating(): SeatMap
+ setSeating(SeatMap)
+ getTime(): String
+ setTime(String)
+ toString(): String

<>
Airline
- airlineName: String
+ Airline(String)
+ reserveFirstClass(Flight, SeatType): Seat
+ reserveEconomy(Flight, SeatType): Seat
+ getAirlineName(): String
+ setAirlineName(String)
+ toString(): String

AirlineReservationApplication
- flights: ArrayList
- airlines: ArrayList
- keyboard: Scanner
*** Your own attributes if you need ***
+ setup()
+ update()
+ main(String[])
*** Your own methods (if you need) to
interact with the core functionality of
Airline Reservation Application!***

SmartLine SimpleWay
+ SmartLine(String)
+ reserveFirstClass(Flight, SeatType): Seat
+ reserveEconomy(Flight, SeatType): Seat
+ SimpleWay(String)
+ reserveFirstClass(Flight, SeatType): Seat
+ reserveEconomy(Flight, SeatType): Seat

Storing Seat Maps and Reservations
In this section, you will develop classes to store seat reservations.
Step 1: SeatPosition class
Design a SeatPosition class which contains the row and column of a seat in the
seat map. E.g.
1A, 6C, 2G.
Step 2: Seat class
Design a Seat class which:
has data (i.e., two attributes) to store whether a seat is reserved or is in  first class.
has data that stores the type of the Seat: AISLE, MIDDLE, WINDOW  (Hint: consider using an enumerated type. E.g., SeatType enum in a  separate file!).
stores a SeatPosition object to form a seat map position.
has toString() method to return a Seat representation according to  the right-hand side of Figure 1. For example,
o if the Seat is in window side of the first-class position and is not  reserved, we can show the Seat like [W _ ]; (Note: The letter for  Seat should be capitalized if the Seat is in the first-class position)
o if the Seat is in window side of economy class position and is  booked, we can show the Seat like [w X ]; (Note: The letter for  Seat should be lowercased if the Seat is in economy class  position)
Write another method called getSeatDescription() that outputs a  longer text description of the Seat. For example:
The economy class MIDDLE seat at 9D is not reserved.
Step 3: An abstract SeatMap class
Develop an abstract SeatMap class which:
has an abstract method with the declaration of abstract protected void initialiseSeatMap().
stores a two-dimensional array of Seat objects according to the righthand side of Figure 1, to be initialized by concrete classes (see below).
contains instance variables that
o store the number of rows and columns that comprise the matrix
o maintains the number of rows situated in first-class seats.
Dr. Seyedjamal Zolhavarieh, Auckland University of Technology, [email protected]
All instance variables are protected in the SeatMap class. You should not write  any set methods. Instead, it has the following functionality to query the
SeatMap:
Provide accessor methods that return the last row (e.g., 10) and last  column (e.g., the character 'G') in the seat mapping.
o public char lastSeatColumn()
o public int lastSeatRow()
• public Seat getSeat(int seatRow, char seatColumn) returns the  Seat in the specified seat map position (Refer to Figure 1).
• public Seat getLeft(Seat aSeat)/ public Seat getRight(Seat aSeat) (two methods) returns a seat to the left or right of the input Seat. (Hint:  use SeatPosition to find the Seat in the 2D array). If the Seat does not  exist, return null.
• public Seat queryAvailableEconomySeat(SeatType aType) returns a  seat in the economy that has the matching SeatType and is not already  booked. If all these types of seats are booked, return any seat in the  economy. If all seats are booked, return null.
• public Seat queryAvailableFirstClassSeat(SeatType aType) is the  same, but only searches first class.
• public String toString() returns a string containing a text  representation of the SeatMap similar to the right-hand side of Figure 1 (the sample representation is as bellow).
A B C D E F G H I
1 [W _ ] [M _ ] [A _ ] [A _ ] [M _ ] [A _ ] [A _ ] [M _ ] [W _ ]
2 [W _ ] [M _ ] [A _ ] [A _ ] [M _ ] [A _ ] [A _ ] [M _ ] [W _ ]
3 [W _ ] [M _ ] [A _ ] [A _ ] [M _ ] [A _ ] [A _ ] [M _ ] [W _ ]
4 [W _ ] [M _ ] [A _ ] [A _ ] [M _ ] [A _ ] [A _ ] [M _ ] [W _ ]
5 [W _ ] [M _ ] [A _ ] [A _ ] [M _ ] [A _ ] [A _ ] [M _ ] [W _ ]
6 [W _ ] [M _ ] [A _ ] [A _ ] [M _ ] [A _ ] [A _ ] [M _ ] [W _ ]
7 [w _ ] [m _ ] [a _ ] [a _ ] [m _ ] [a _ ] [a _ ] [m _ ] [w _ ]
8 [w _ ] [m _ ] [a _ ] [a _ ] [m _ ] [a _ ] [a _ ] [m _ ] [w _ ]
9 [w _ ] [m _ ] [a _ ] [a _ ] [m _ ] [a _ ] [a _ ] [m _ ] [w _ ]
10 [w _ ] [m _ ] [a _ ] [a _ ] [m _ ] [a _ ] [a _ ] [m _ ] [w _ ]
11 [w _ ] [m _ ] [a _ ] [a _ ] [m _ ] [a _ ] [a _ ] [m _ ] [w _ ]
12 [w _ ] [m _ ] [a _ ] [a _ ] [m _ ] [a _ ] [a _ ] [m _ ] [w _ ]
Step 4: Developing two classes that extend SeatMap class.
Develop a BoeingSeatMap class (extends SeatMap class) which:
o has a default constructor initialising the number of rows to 10, the  number of columns to 7, and the number of first-class rows to 4.
Dr. Seyedjamal Zolhavarieh, Auckland University of Technology, [email protected]
The constructor initialises the seat array accordingly. The  constructor calls the initialiseSeatMap method.
o Write an algorithm in initialiseSeatMap method to populate the  seat array according to Figure 3.
Develop a AirBusSeatMap class (extends SeatMap class) which:
o has a default constructor initialising the number of rows to 12, the  number of columns to 9, and the number of first-class rows to 6. The constructor initialises the seat array accordingly. The  constructor calls the initialiseSeatMap method.
o Write an algorithm in initialiseSeatMap to populate the seat array  according to Figure 3.
Note:
initialiseSeatMap instantiates each Seat object stored in the seat array  with the appropriate SeatPosition object by translating the array indices to a
SeatPosition.
Figure 3: SeatMap subclasses: BoeingSeatMap and AirBusSeatMap
COMP503/ENSE502/ENSE602 _ Assignment 2
Sem 1 2020
Dr. Seyedjamal Zolhavarieh, Auckland University of Technology, [email protected]
Flights
Design a Flight class to store information relating to a flight. The information
contains the
origin and destination cities, departure time, flight number, and
a
SeatMap object that stores the seat map. Consider the data you will need to
store to implement the functionality of the Airline Reservation Application.
Booking a Flight Seat
Airlines query a flight's seating map to determine the availability of seats.
Create an abstract class Airline which
o contains a descriptive name of the Airline and get/set methods.
o has a toString method that prints out a nice representation of the  object.
o has two abstract methods:
§ abstract public Seat reserveFirstClass(Flight aFlight, SeatType aType)
§ abstract public Seat reserveEconomy(Flight aFlight, SeatType aType)
Airline is extended by two concrete classes SimpleWay and SmartLine, and each class overrides the abstract methods inherited from Airline and implements the booking based on the following Airline's seat  booking policies.
Airline Reservation Policies
Different Airlines have different booking policies if the requested seating is  unavailable on a flight. Consider the policies of the following two Airlines:
SimpleWay
1) Seat Reservation in First Class
a) Find and book a seat in first class that matches the requested seat type
b) If no such first-class seat with the matching type exists, then find and  book any seat in the first-class Seat.
c) If there are no seats available in the first class, then find and reserve a  middle or window seat in economy class, also reserving one of the  neighbouring seats (for extra passenger room).
d) If no seats are matching any of these criteria, then a reservation cannot  be made
2) Seat Reservation in Economy Class
a) Find and reserve a seat in economy class that matches the requested  seat type
b) If no such economy class seat with the matching type exists, then find  and reserve Seat in economy class
c) If no seats are matching any of these criteria, then a reservation cannot  be made
SmartLine
1) Seat Reservation in First Class
a) Find and book a seat in first class that matches the requested seat type
b) If no such first-class class seat with the matching type exist, then find  and reserve any seat in first-class.
c) If there are no seats available in first class then find and reserve a middle  seat in economy class, also reserving both the left and right  neighbouring seats (for extra passenger room)
d) If no seats are matching any of these criteria, then a reservation cannot  be made
2) Seat Reservation in Economy Class
a) Find and reserve a seat in economy class that matches the requested  seat type
b) If no such economy class seat with the matching type exists, then find  and reserve any seat in economy class.
c) If no seats are matching any of these criteria, then a reservation cannot  be made
Program Interaction
Develop an application class called AirlineReservationApplication, which  interacts with the core functionality of the Airline Reservation Application. You  may consider writing additional methods to simulate the application. Your  program should involve multiple flight journeys to select from different seating
configurations (BoeingSeatMap and AirBusSeatMap) and demonstrate both  airline seat booking policies. The airlines' policies should be applicable for all
flights.
The Airline Reservation Application provides menu interactions for
1) Selecting an airline to apply booking policies
2) Booking economy or first-class seats for a flight using an airline policy
A text file "
flights.txt" is provided to you with this assignment. It contains the  flights' info with reserved seats in flights shown in the "sample-output.txt" file.
In your AirlineReservationApplication class, write a static method which reads  this "flights.txt" file, and has the following signature: public static void setup() throws NumberFormatException, IOException
This method reads the text file and throws the following exceptions:
1) IOException, thrown if the file cannot be opened/read
2) NumberFormatException, thrown if integer parsing fails
This method should run first when the application is started to update the  system and make it ready to function. Using this static method needs to use  three static variables. The variables should be static and out of the setup()  method as they should be available for the other methods as well:
• private static ArrayList flights;
o to store multiple flight objects.
• private static ArrayList airlines;
o to store airline objects.
private static Scanner keyboard = new Scanner(System.in);
o to read user input.
You also need to write a static method called update() to write the updated  flight information into the "flights.txt": public static void update() throws IOException
You need to keep the flight data and add it to the existing file. The method  throws the IOException if the file cannot be opened/written.
Your main method should try to read/write the data (using setup and update  methods), appropriately handling exceptions (potentially by terminating  execution with a meaningful message but not by an uncaught exception). The  application should always keep up-to-date data.
Note: Your application should also elegantly handle exceptions occurring from
bad user input.
Some notes about the "
flights.txt" file structure:
First-line in the file: a number to show the number of flights we have
After first line, you will have 6 lines for each flight. For example, if you  have 2 in the first line, you will have 12 lines after that. Every 6 lines is  related to a flight:
o "@Flight": starting a flight information
o "@F_info": the next line has flight information separated by ','
(comma) character (i.e. flight_number,origin, destination,
departure_time, seat map type).

o "@F_R_Seats": the next line has the list of reserved seats
separated by ',' (comma) character (i.e. seat_info_one,
seat_info_two, …). seat info contains row and column of Seat
separated by '_' (underline) character (i.e., 1_A).
o "@@":end of a flight information
Marking Scheme
Criteria: Weight: Grade A
Grade Range:
100 ≥ x ≥ 80%
Grade B
Grade Range:
80 > x ≥ 65%
Grade C
Grade Range:
65 > x ≥ 50%
Grade D
Grade Range:
50 > x ≥ 0%
Functionality of
SeatMap
classes
25% OOP paradigm consistently
used forthe
implementation of all
SeatMap functionality.
Inconsistent use of OOP
paradigm butthecorrect
implementation ofSeatMap
functionality
IncorrectSeatMap
functionality and poor use of
OOP paradigm
AbsentSeatMap
functionality or code does
not compile
Functionality of
Airline
classes
20% OOP paradigm consistently
used forthe
implementation of allairline
functionality.
Inconsistent use of OOP
paradigm butthecorrect
implementation ofairline
functionality
Some basic functionality of
airline classes/poor usage of
abstract and concrete classes
Absent functionality of
airline classes or code does
not compile.
Program's
Runtime
Demonstration:
-Uniqueness
-Purpose
-Context
-Interactive
30% Theobject-oriented
program is unique,
purposeful, and provides an
elegant implementation of
theAirline Reservation
Application.The program is
interactive.
The object-oriented program
is unique, purposeful.A
reasonable implementation of
theAirline Reservation
Application.
The program is interactive.
The object-oriented program
features an incomplete
demonstration of the Airline
Reservation Application
Program is not interactive.
Absent functionality of
Airline Reservation
Application or code does not
runafter compiling
Code Quality:
-Whitespace
-Naming
-Reuse
-Modularity
-Encapsulation
15% Whitespace is
comprehensively consistent.
All naming is sensible and
meaningful. Code reuse is
present.The code is
modular.The code is well
encapsulated.
Whitespace is
comprehensively consistent.
The majority of naming is
sensible.The code is modular.
The code is encapsulated.
Whitespace is
comprehensively consistent.
The code has some
modularity.
The code has some
encapsulation.
Whitespace is inconsistent,
and hence code is difficult to
read.
Documentation
Standards:
-Algorithms
Commented
-Javadoc
10% The entire codebase has
comprehensive Javadoc
commenting. Algorithms are
well commented.
The majority of the codebase
features Javadoc
commenting.The majority of
algorithms are commented.
Some Javadoc comments
present. Some algorithms are
commented.
No Javadoc comments
present.
Javadoc Commenting
1. Your classes must have commenting of the form:
/**
* Comment describing the class.
* @author yourname studentnumber
**/
2. All methods must be commented with appropriate Javadocs metatags. For example:
/**
* A comment to describe the method
* @param a first parameter description
* @param b second parameter description
* @return a description of the returned result
* @author studentnumber

* */
Authenticity
Remember!
It is unacceptable to hand in any code which has previously been  submitted for assessment (for any paper, including Programming 2) or  available online
All work submitted must be unique and your own!

Submission Instructions

Submit the following documents as an archive .zip file of your documents on
Blackboard before the deadline:
Your full java project for assignment.
Sample console output demonstrating your program in use (.txt file)
Zip structure and file naming requirements. Please ensure your submission  matches the following:
4 lastname-firstname-studentid.zip
2 Project folder (can be found in your workspace)
2 studentid-console-sample.txt
Replace the underlined text with your details.
An extension will only be considered with a Special Consideration Form  approved by the School Registrar. These forms are available at AUT  Blackboard.
You will receive your marked assignment via Blackboard. Please look over your  entire assignment to make sure that it has been marked correctly. If you have  any concerns, you must raise them with the lecturer. You have
one week to  raise any concerns regarding your mark. After that time, your mark cannot be  changed.
Do not go to the lecturer because you do not like your mark. Only go if you feel  something has been mismarked.