CPT121 / COSC2135 Programming 1 (OUA) Assignment 2 Java FlightBookingSystem
The scenario for this assignment is presented as follow
CountryAir is a small regional charter airline company operating passenger and cargo Flights. The company would like to hire a programmer to design and implement a simulator for the airline booking terminal. The system you are about to develop should allow CountryAir booking staff to maintain the details for flights that the airline is running. A summary of the user interviews in which requirements for this stage were presented is given below:
George: Flight Schedule manager
Our company would like to have system that will allow staff to perform the following tasks from the terminal:
• Schedule a flight
• Display destinations of all flights in the system
• Add passengers to a flight
• Add a parcel to a flight
• Display Flight Manifest
As a flight scheduler, I would like to have a system that will allow any flight scheduler to schedule company flights, check flight manifest, and whenever required view final destinations for all flights. As a scheduler, all I need to know when scheduling a flight is the flight number and destination. For passenger flights I need to know the flight capacity, so the crew will not exceed the number of passengers. For cargo flights I need to monitor the number of parcels and the maximum weight the flight can carry. Before the flight take off, I usually print flight manifest and hand a copy to the pilot. The flight manifest normally includes details such as flight scheduled time, flight number, and the number of passengers onboard and their details. For cargo flights I need extra information such as total number of parcels and maximum weight. For recording purposes, I sometimes need to retrieve final destinations of all flights in the system. There are other tasks that our flight crew are assigned to do. Pamela, our flight crew supervisor will list the tasks specifically for flight crew.
Pamela: Flight Crew Supervisor
Adding passengers and parcels to flights, displaying flight destinations, checking flight manifests are just some of the day to day tasks we perform. We would like to have a system that will help our crew perform the above tasks effortlessly. What crew normally does when adding a passenger to a flight, is to gather passenger information such as name and destination. Once these are collected, a passenger is added to a flight. Here we assume the crew has confirmed that the flight and passengers are heading to the same destination or transiting. To add a parcel to a flight a crew need some parcel information such as parcel Id, weight and where the parcel is going. We need to keep track of number of parcels we add to the flight as cargo flights are constrained in the number of parcels and their weights. We do not exceed the maximum weight a cargo flight is designed to carry, regardless of number of parcels, if the maximum weight is reached, the crew will stop adding parcels to the flight. As George explained in his interview above, the other tasks such as printing flight manifest and retrieving final destinations for all flights are common to all staff.
4.2.1) Stage A – Modelling and implementing classes to represent Flight, Passenger and Parcel classes (3 marks)
In this stage you will be designing and implementing Java classes Flight, Parcel and Passenger which will act as a blueprint from which Flight, Parcel and Passenger objects can be created (and ultimately stored) in the system. These classes should capture information relevant to create Flight, Parcel and Passenger objects such those listed in the scenario above. They should provide accessors which are required to facilitate application-level functionality outlined in Stage B and C of this assignment. The information entered for flights, passengers and parcels should be displayed, so these classes should provide methods that will fully facilitate display of information for flights, passengers and parcel in a neat and labelled format.
IMPORTANT NOTES WHEN IMPLEMENTING THIS CLASS:
You are expected to adhere to all relevant object-oriented programming guidelines, including:
• Visibility of instance variables and methods set appropriately
• Instance variable initialisations carried out in the constructor only
• No unnecessary accessors (setters) or mutators (getters) – only provide methods which will be needed when implementing the application class in stage C
• Methods should work with instance variables when performing their required task
• Parameter lists in methods should be appropriate to the task the method is performing – only accept parameters where a method requires one or more values from the caller to perform its assigned task that it does not already have access to.
• Methods which need to communicate a value or result back to the caller should do by returning the value in question, not by storing it in an instance variable or printing it to the screen.
• Data classes should not implement any application-level functionality – eg. prompting for / getting input from the user, managing a collection of objects at a high level, etc.
Functional requirements for Stage A will be assessed as follows:
Criteria | Excellent | Good | Needs Improvement | Poor |
4.2.1 Flight class: Instance variable definitions (0.4 marks) |
(0.4 marks) Instance variables of appropriate type defined for all required values. No additional instance variables declared at class level – variables required for calculations or other tasks in a specific method defined locally within that method. Visibility of instance variables set to private as per good object-oriented programming practice. |
(0.3 marks) All required instance variables defined – some issues noted with types chosen or visibility of instance variables, additional instance variables which should be declared locally within the methods that use them, not defined for all relevant rates. |
(0.1 marks) Some evidence of an attempt to define required instance variables – significant issues with missing variables / constants, or incorrect visibility. |
(0 marks) Code implemented instance variable definitions generally do not meet expectations and is not functional or is absent altogether. |
4.2.1 Flight Class: Constructor / Accessors (0.4 marks) |
(0.4 marks) Constructor defined correctly allowing class user to create and initialise new flight with values passed in as parameters. Accessors (getters) implemented correctly and only for instance variables the class user needs to retrieve, no additional accessors or mutators included. |
(0.3 marks) Constructor and all required accessors defined as required – some issues noted with constructor parameters / instance variable initialisation, or with additional accessors and/or mutators provided which shouldn’t be included in the class definition. |
(0.1 marks) Some evidence of an attempt to define constructor and/or accessors – significant issues noted with one or more expectations, or code is not functional. |
(0 marks) Code implemented for constructor and accessors generally does not meet expectations and is not functional or is absent altogether. |
4.2.1 Flight class: printFlightDetails() method (0.2 marks) |
(0.2 marks) printFlightDetails() method defined – method signature correct, Flight details printed in near / |
(0.1 marks) printFlightDetails() method defined – some issues noted with method signature or |
(0.05 marks) Some evidence of an attempt to implement printFlightDetails() method – significant |
(0 marks) Code implemented for printing of flight details generally |
P a g e 6 | 14
labelled format as required. |
printing of flight details (eg. missing details, output not formatted / labelled neatly, etc) |
issues noted with one or more expectations, or code is not functional. |
does not meet expectations and is not functional, or is absent altogether |
|
4.2.1 Passenger class: Instance variable definitions (0.4 marks) |
(0.4 marks) Instance variables of appropriate type defined for all required values. No additional instance variables declared at class level – variables required for calculations or other tasks in a specific method defined locally within that method. Visibility of instance variables set to private as per good object-oriented programming practice. |
(0.3 marks) All required instance variables defined – some issues noted with types chosen or visibility of instance variables, additional instance variables which should be declared locally within the methods that use them, not defined for all relevant rates. |
(0.1 marks) Some evidence of an attempt to define required instance variables – significant issues with missing variables / constants, or incorrect visibility. |
(0 marks) Code implemented instance variable definitions generally do not meet expectations and is not functional or is absent altogether. |
4.2.1 Passenger Class: Constructor / Accessors (0.4 marks) |
(0.4 marks) Constructor defined correctly allowing class user to create and initialise new passenger with values passed in as parameters. Accessors (getters) implemented correctly and only for instance variables the class user needs to retrieve, no additional accessors or mutators included. |
(0.3 marks) Constructor and all required accessors defined as required – some issues noted with constructor parameters / instance variable initialisation, or with additional accessors and/or mutators provided which shouldn’t be included in the class definition. |
(0.1 marks) Some evidence of an attempt to define constructor and/or accessors – significant issues noted with one or more expectations, or code is not functional. |
(0 marks) Code implemented for constructor and accessors generally does not meet expectations and is not functional or is absent altogether. |
4.2.1 Passenger class: printPassengerDetails() method (0.2 marks) |
(0.2 marks) printPassengerDetails() method defined – method signature correct, passenger details printed in near / labelled format as required. |
(0.1 marks) printPassengerDetails() method defined – some issues noted with method signature or printing of passenger details (eg. missing details, output not formatted / labelled neatly, etc) |
(0.05 marks) Some evidence of an attempt to implement printPassengerDetails() method – significant issues noted with one or more expectations, or code is not functional. |
(0 marks) Code implemented for printing of passenger details generally does not meet expectations and is not functional, or is absent altogether |
4.2.1 Parcel class: Instance variable / constant definitions (0.4 marks) |
(0.4 marks) Instance variables of appropriate type defined for all required values. No additional instance variables declared at class level – variables required for calculations or other tasks in a specific method defined locally within that method. Visibility of instance variables set to private as per good |
(0.3 marks) All required instance variables and constants defined – some issues noted with types chosen or visibility of instance variables, additional instance variables which should be declared locally within the methods that use them, not defined for all relevant rates. |
(0.1 marks) Some evidence of an attempt to define required instance variables – significant issues with missing variables / constants, or incorrect visibility. |
(0 marks) Code implemented instance variable definitions generally do not meet expectations and is not functional or is absent altogether. |
P a g e 7 | 14
object-oriented programming practice. |
||||
4.2.1 Parcel Class: Constructor / Accessors (0.4 marks) |
(0.4 marks) Constructor defined correctly allowing class user to create and initialise new parcel with values passed in as parameters. Accessors (getters) implemented correctly and only for instance variables the class user needs to retrieve, no additional accessors or mutators included. |
(0.3 marks) Constructor and all required accessors defined as required – some issues noted with constructor parameters / instance variable initialisation, or with additional accessors and/or mutators provided which shouldn’t be included in the class definition. |
(0.1 marks) Some evidence of an attempt to define constructor and/or accessors – significant issues noted with one or more expectations, or code is not functional. |
(0 marks) Code implemented for constructor and accessors generally does not meet expectations and is not functional or is absent altogether. |
4.2.1 Parcel class: printParcelDetails() method (0.2 marks) |
(0.2 marks) printParcelDetails() method defined – method signature correct, parcel details printed in near / labelled format as required. |
(0.1 marks) printParcelDetails() method defined – some issues noted with method signature or printing of parcel details (eg. missing details, output not formatted / labelled neatly, etc) |
(0.05 marks) Some evidence of an attempt to implement printParcelDetails() method – significant issues noted with one or more expectations, or code is not functional. |
(0 marks) Code implemented for printing of parcel details generally does not meet expectations and is not functional, or is absent altogether |
The functional requirements for Stage B involve extending the class Flight to allow objects of type PassengerFlight and Cargo
Flight to be created from sub-classes PassengerFlight and Cargo Flight, respectively:
4.2.2) Stage B – Modelling and implementing classes to represent PassengerFlight and CargoFlight subclasses (2 marks)
In this stage you will be designing and implementing a Java classes PassengerFlight and CargoFlight which both extends Flight
class from which PassengerFlight and CargoFlight objects can be created (and ultimately stored) in the system.
These subclasses should apply inheritance concepts to create PassengerFlight and CargoFlight objects with additional instance
variable defined according to the interviews above. These sub-classes should provide accessor which are required to facilitate
application-level functionality outlined in Stage C.
The PassengerFlight class should facilitate the process of adding passengers to a flight by defining appropriate method that will
be invoked when system users opt to add passenger to a flight and consider the restrictions imposed in the process. Likewise,
CargoFlight class should facilitate the process of adding parcels to a flight defining appropriate method that will be invoked when
system users opt to add parcels to the flight and consider the constraints imposed on the maximum weight and number of
parcels.
Each subclass should override printFlightDetails() method to include additional information from its own. The details of
passenger flight, list of passengers on board, flight capacity should be displayed in a neat, labelled format when details for
passenger flight objects are required. In the case of Cargo flight objects, the method should include information about parcels in
the flight (number, total weight of all parcels) and any additional instance variable for this class. These details should be displayed
in a neat, labelled format.
P a g e 8 | 14
IMPORTANT NOTES WHEN IMPLEMENTING THESE SUB-CLASSES:
You are expected to adhere to all relevant object-oriented programming guidelines, including:
• Visibility of instance variables and methods set appropriately
• Instance variables already declared in the super class should not be declared in subclass
• Instance variable initialisations carried out in the constructor only
• Methods should work with instance variables when performing their required task
Functional requirements for Stage B will be assessed as follows:
Criteria | Excellent | Good | Needs Improvement | Poor |
4.2.2 PassengerFlight Subclass Instance variable (0.25 marks) |
(0.25 marks) A subclass PassengerFlight that extends Flight is correctly defined and instance variables declared. |
(0.2 marks) A subclass defined – some issues noted with types chosen or visibility of instance variables |
(0.1 marks) Some evidence of an attempt to define a subclass – significant issues with missing variable or incorrect visibility. |
(0 marks) Code implemented for subclass definition generally do not meet expectations and is not functional or is absent altogether. |
4.2.2 PassengerFlight Subclass constructor / Accessor (0.25 marks) |
(0.25 marks) Subclass constructor defined correctly allowing super class to instantiate the rest of the instance variables. Additional in instance variable defined and instantiated. Accessor (getter) implemented correctly. |
(0.2 marks) Subclass constructor and all required accessors defined as required – some issues noted with constructor parameters / instance variable initialisation, or with additional accessors and/or mutators provided which shouldn’t be included in the class definition. |
(0.1 marks) Some evidence of an attempt to define subclass constructor and/or accessors – significant issues noted with one or more expectations, or code is not functional. |
(0 marks) Code implemented for subclass constructor and accessors generally does not meet expectations and is not functional or is absent altogether. |
4.2.2 addPassenger(Passen ger p) method (0.25 marks) |
(0.25 marks) addPassenger(Passen ger p) method correctly defined in the subclass – return type / method signature. Adding passengers correctly implemented. |
(0.2 marks) addPassenger(Passen ger p) defined – some issues noted with method signature, checking condition for adding passengers. |
(0.1 marks) Some evidence of an attempt to define addPassenger(Passen ger p) method – significant issues noted with one or more expectations, or code is not functional. |
(0 marks) Code implemented to define addPassenger(Passen ger p) generally does not meet expectations and is not functional or is absent altogether. |
4.2.2 Overriding printFlightDetails() method (0.25 marks) |
(0.25 marks) printFlightDetails() method overridden correctly in the subclass – method signature correct, flight details printed in near / labelled format as required. |
(0.2 marks) printFlightDetails() method overridden – some issues noted with method signature or printing of flight details (e.g. missing details, output not formatted / labelled neatly, etc) |
(0.1 marks) Some evidence of an attempt to override printFlightDetails() method – significant issues noted with one or more expectations, or code is not functional. |
(0 marks) Code implemented to override printing of flight details generally does not meet expectations and is not functional, or is absent altogether |
4.2.2 CargoFlight Subclass Instance variable (0.25 marks) |
(0.25 marks) A subclass CargoFlight that extends Flight is correctly defined and instance variables declared. |
(0.2 marks) A subclass defined – some issues noted with types chosen or visibility of instance variables |
(0.1 marks) Some evidence of an attempt to define a subclass – significant issues with missing variable or incorrect visibility. |
(0 marks) Code implemented for subclass definition generally do not meet expectations and is not functional or is absent altogether. |
4.2.2 CargoFlight Subclass constructor / Accessor (0.25 marks) |
(0.25 marks) Subclass constructor defined correctly allowing super class to instantiate the rest of the instance variables. Additional in instance variable defined and instantiated. Accessor (getter) implemented correctly. |
(0.2 marks) Subclass constructor and all required accessors defined as required – some issues noted with constructor parameters / instance variable initialisation, or with additional accessors and/or mutators provided which shouldn’t be included in the class definition. |
(0.1 marks) Some evidence of an attempt to define subclass constructor and/or accessors – significant issues noted with one or more expectations, or code is not functional. |
(0 marks) Code implemented for subclass constructor and accessors generally does not meet expectations and is not functional or is absent altogether. |
4.2.2 addParcel(Parcel p) method (0.25 marks) |
(0.25 marks) addParcel(Parcel p) method correctly defined in the subclass – return type / method signature. Adding parcels correctly implemented. |
(0.2 marks) addParcel(Parcel p) defined – some issues noted with method signature, checking condition for adding parcels. |
(0.1 marks) Some evidence of an attempt to define addParcel(Parcel p) method – significant issues noted with one or more expectations, or code is not functional. |
(0 marks) Code implemented to define addParcel(Parcel p) generally does not meet expectations and is not functional or is absent altogether. |
4.2.2 Overriding printFlightDetails() method (0.25 marks) |
(0.25 marks) printFlightDetails() method overridden correctly in the subclass – method signature correct, flight details printed in near / labelled format as required. |
(0.2 marks) printFlightDetails() method defined – some issues noted with method signature or printing of flight details (e.g. missing details, output not formatted / labelled neatly, etc) |
(0.1 marks) Some evidence of an attempt to implement printFlightDetails() method – significant issues noted with one or more expectations, or code is not functional. |
(0 marks) Code implemented for printing of flight details generally does not meet expectations and is not functional, or is absent altogether |
The functional requirements for stage C involve implementing an application which allows the user to manage a collection of Flights:
4.2.3) Stage C- FlightBookingSystem Application (3 marks)
In this stage you will be implementing a second console-driven application in Java which provides functionality to the user allowing them to create, store and manage Flight objects (PassengerFlight and CargoFlight) objects in the system. A summary of the system requirements for this stage is presented is given below:
“A menu-driven system which allows users to manage flight bookings – features they plan on using on a day-to-day basis
include the following:
• | A – Schedule a Passenger Flight to the system The user will provide all relevant details required to create a passenger flight object such as flight number, |
destination, and the capacity i.e. number of passengers the flight can carry, the system will then create a passengerflight object and store in the array.
• | B – Schedule a Cargo Flight to the system User will provide all relevant details required to create a cargo flight object such as flight number, destination, and |
maximum weight i.e. maximum weight the flight can carry, the system will then create a cargoflight object and store in the array.
• C – Add Passenger to a Flight
User will provide all relevant details required to create a passenger object, then system will create a passenger object and store in the array. The user will then provide a flight number. If flight is found and it is not full, the system should add the passenger to that flight. If the specified flight number is not found, then the system should inform the user that the search has failed. If the flight is full, the system should notify the user and returning to the menu is fine in this situation.
• D – Add a Parcel to a Flight
User will provide all relevant details required to create a parcel object, then system will create a parcel object and store in the array. The user will then provide a flight number. If flight is found and has not exceed the weight or the number of parcels, the system should add the parcel to that flight. If the specified flight number is not found, then the system should inform the user that the search has failed. If the flight cannot add any parcel, the system should notify the user the reasons and return to the menu.
• | E – Display Flight Destinations |
We would like to have a system that displays to the screen the flight destinations and flight numbers in a neat, labelled format – an example of how the information appears on our current system is shown below: |
|
Flight Number: QF101 |
Flight Destination: Sydney |
VA730 | Gold Coast |
• F – Display Flight Manifest
We would like to be able to quickly print flight manifest on the screen by providing flight number. The printed information should contain the flight number, Capacity (passengers capacity or maximum weight), number of passengers boarded or number of parcels added, passenger or parcel destination.
The report should be displayed in a neat, labelled format – an example of how the information appears on our current system for Passenger or Cargo Flight is shown below:
For Passenger Flight Manifest
Flight Number: QF101 |
Capacity: 400 |
Number of Passengers: 350 |
Destination: Sydney |
|
For Cargo Flight Manifest Flight Number: Maximum Weight: |
Destination: | |||
Number of Parcels: Total weight: | ||||
QF507 T= Tonnes |
700T | 300 | 690T | Karratha |
Your task here is to implement a menu-driven application in Java which does the following: | ||||
• | Declare and create storage for up to 30 Flight objects. |
• Present a simple menu in your main() method, which allows the user to select from the features outlined above, or exit the program when they choose to from the menu – this code has been provided in the sample FlightBookingSystem.java source code file – you will need to import (or copy + paste) this code into your project.
• Implement each of the features outlined above as described – the code for each feature should be implemented in a separate method inside the FlightBookingSystem class and each corresponding menu option should call the corresponding method(s) as required.
IMPORTANT NOTES WHEN IMPLEMENTING THIS APPLICATION CLASS:
• The menu should use suitable repetition and decision structures to allow the user to keep selecting required menu options until they choose to exit, by selecting the exit (“X”) option.
• After the processing for a selected option is complete (or the user has entered an invalid selection) the program should return to the menu, at which point the menu options should be displayed again and the user prompted to enter their (next) selection.
• The menu options the user is prompted to enter should be numbered from “A” to” F”, with ‘X” for the “exit” option, and the menu should be user-friendly allowing the user to enter both lower and upper-case versions of each option. If the user enters an invalid selection ( i.e. one not in the specified range) then a suitable error message should be displayed.
• The user should be prompted in a user-friendly manner where user input is required and messages displaying the outcome after the execution of a feature should be displayed for both successful and unsuccessful actions.
• Input validation is not specifically required in any feature (especially in relation to range or type of values entered, – you may assume the user will enter valid values for all feature inputs. The program should, however, report on invalid menu selections and failed searches as outlined in the feature descriptions above.
• This application class should not be accessing any instance variables stored within the PassengerFlight objects or CargoFlight objects it is storing and any interaction with these objects at the application class level should be via the methods described and implemented in Stage A of this assignment.
• You may assume that the user (Flight Scheduler) will not schedule more Flights than there is room for in the collection of Flight objects.
Functional requirements for Stage C will be assessed as follows:
Criteria | Excellent | Good | Needs Improvement | Poor |
4.2.3 SchedulePassengerFlight() feature (0.5 marks) |
(0.5 marks) User prompted to enter required details and new PassengerFlight object created and stored in collection of Flight correctly. |
(0.3 marks) SchedulePassengerFlig ht() feature implemented – some issues noted with scheduling a PassengerFlight object or storing of new PassengerFlight in collection of Flights. |
(0.1 marks) Some evidence of an attempt to schedule a PassengerFlight and/or add it to collection of PassengerFlight – significant issues noted with one or more expectations, or code is not functional. |
(0 marks) Code implemented for scheduling PassengerFlight generally does not meet expectations and is not functional or is absent altogether. |
4.2.3 ScheduleCargoFlight() feature (0.5 marks) |
(0.5 marks) User prompted to enter required details and new CargoFlight object created and stored in the collection of Flight correctly. |
(0.4 marks) SchedulePassengerFlig ht() feature implemented – some issues noted with scheduling a CargoFlight object or storing of new CargoFlight in the collection of Flight. |
(0.2 marks) Some evidence of an attempt to schedule a CargoFlight and/or add it to collection of CargoFlight – significant issues noted with one or more expectations, or code is not functional. |
(0 marks) Code implemented for scheduling a CargoFlight generally does not meet expectations and is not functional or is absent altogether. |
4.2.3 AddPassenger() feature (0.5 marks) |
(0.5 marks) User prompted to enter required details to create a passenger object. User prompted for flight number, search for specified flight no. implemented using appropriate search technique, then system added passenger to flight polymorphically. Failed searches reported back to the user appropriately |
(0.3 marks) Adding passenger feature implemented issues noted with adding passenger/search technique / application of polymorphism to add passenger to the flight. |
(0.1 marks) Some evidence of an attempt to add passenger feature implemented significant issues noted with one or more expectations, or code is not functional. |
(0 marks) Code implemented for adding passenger generally does not meet expectations and is not functional or is absent altogether. |
4.2.3 AddParcel() feature (0.5 marks) |
(0.5 marks) User prompted to enter required details to create a parcel object. User prompted for flight number, search for specified flight no. implemented using appropriate search technique, then system added parcel to flight polymorphically. Failed searches reported back to the user appropriately |
(0.3 marks) Adding passenger feature implemented issues noted with adding parcel/search technique / application of polymorphism to add parcel to the flight. |
(0.1 marks) Some evidence of an attempt to add parcel feature implemented significant issues noted with one or more expectations, or code is not functional. |
(0 marks) Code implemented for adding parcel generally does not meet expectations and is not functional or is absent altogether. |
4.2.3 displayFlightDestination() feature (0.5 marks) |
(0.5 marks) The feature displays flight numbers and flight destinations as expected, in a in a neat, labelled format. |
(0.3 marks) Feature to display flight destinations implemented- some issues noted with call to accessors /formatting/ labelling /the use of loops |
(0.1 marks) Some evidence of attempt to implement display flight destinations feature- significant issues noted with one or more expectations, or code is not functional. |
(0 marks) Code implemented for displaying flight destinations generally doesn’t meet expectations and is not functional or is absent altogether. |
4.2.3 displayFlightManifest() feature (0.5 marks) |
(0.5 marks) User prompted to enter flight number, a search for specified flight number was implemented using appropriate search techniques. Appropriate polymorphic method call to print flight manifest. Failed searches reported back to the user appropriately. |
(0.3 marks) diplayFlightManifest() feature implemented some issues noted with search technique /calling method/ or reporting failed searches. |
(0.1 marks) Some evidence of attempt to implement display of flight manifest feature – significant issues noted with one or more expectations, or code is not functional. |
(0 marks) Code implemented for displaying flight manifest generally does not meet expectations and is not functional, or is absent altogether |
- File Format: .java