Question
In java do not use try catch Design For this project, will need to design and implement the following classes (at a minimum): Reservation Class:
In java
do not use try catch
Design
For this project, will need to design and implement the following classes (at a minimum):
Reservation Class:
The class should store the first name, last name, flight price, seat number and seat letter. The class should provide the following methods, at a minimum:
print: Returns a String that contains the information in the reservation
getPrice: Returns the price of the reservation
ReservationSystem Class: The class should store an ArrayList of Reservations.
The class should provide the following methods:
addReservation: Takes as input last name, first name, price, seat number and seat letter and
creates a Reservation with this information. Add the reservation to the list of reservations.
addReservation: Prompts the user for the info needed to make a new reservation. Add the
reservation to the list of reservations.
findReservation: find a reservation by first and last name and returns it
viewReservations: prints all reservations using System.out. Use the print method provided by Reservation
uploadReservations: asks the user for a file and reads in all the reservations from a file and saves them in the ArrayList. Uses the addReservation method for help.
downloadReservations: takes a file as input and writes the reservations to the file. Use theprint method provided by Reservation
updateReservation: asks the user for the first and last name of the reservation to update and then asks for the data to be updated and updates the reservation.
getTotalPrice: Calls getPrice on each individual Reservation and adds them all up
Documentation:
All methods implemented should have javadoc comments written for them.
Program Input:
Your program will display a welcome message to the user and a menu of options for the user to choose from
Welcome to MCCs Airline Reservation System. Please choose from the following options:
1.Uploadreservations
2.Newreservation
3.UpdateReservation
4.Viewallexistingreservations
5.Findreservation
6.Downloadstatistics
7.Exit the program
After completing a task, the main menu will be displayed again.
Program Options
Option 1: Upload Reservations
If the user chooses this option, the program will a. Prompt the user for the file that contains the reservations. b. ReadintherecordsintotheReservationSystem.
Input File Format: LastName FirstName Price SeatNumber SeatLetter Sample Input File:
Bob Mike 200 23 B Matt Benjamin 178 15 A Keller Helen 135.99 6 D Tim Mary 210.77 12 B
Use the uploadReservations method to upload the reservations to the ReservationSystem.
Option 2: New Reservation
This option will prompt the user for the information needed to make 1 reservation and store it in theReservationSystem.
You need to make sure that the seat number is between 1-30. You need to make sure the seat letter is either A, B, C, D or E.
Option 3: Update Reservation
When this option is selected, the program will ask for the first and last name of the reservation and prompt the user for the seat number and seat letter. Use the updateReservation method for this task.
Option 4: View All Existing Reservations
If the user chooses this option, the program will print to the screen all the reservations information. Use the viewReservations method for this task.
Sample Output:
Name: Mike Bob, Price: 200, Seat: 23B Name: Benjamin Matt, Price: 178, Seat: 15A Name: Helen Keller, Price: 135.99, Seat: 6D Name: Mary Tim, Price: 210.77, Seat: 12B
Option 5: Find Reservation
If the user chooses this option, the program will prompt the user for their first and last name and search for a reservation with that first and last name combination and display it to the screen. If no reservation is found, a message will be displayed indicating that. Use the findReservation method for this task.
Option 6: Download Statistics
If the user chooses this option, the program will create a statistics file with the following data:
Printout of all reservations use the downloadReservations method for this task
Sorted customer names alphabetically (by last name)
Lowest flight price
Highestflightprice
Total cost of reservations use the getTotalPrice method in the ReservationSystemclass
4. The statistics file will have the same name as the input file (from option 1) but with _stats.txtappended to it.
For example, if the input file was named reservations.txt, the stats file will be namedreservations_stats.txt.
Note: It will remove the .txt from reservations.txt, before adding the _stats.txt. It will NOT create a file with the name reservations.txt_stats.txt. You can use the string substr method to remove the last 4 characters from the file name.
Write a static function called CreateStatsFile to do this task. Choose the appropriate parameters and return type.
Option 5: Exit the Program
If the user chooses this option, the program will exit. Note: If any other option (other than exit) is chosen, the task will be performed and then the menu will be displayed again.
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