Question
I have finished this project. however, there are bugs. first. I don't know how to add reservations.txt and reservations_stats.txt in the project folder. Final Project
I have finished this project.
however, there are bugs.
first. I don't know how to add reservations.txt and reservations_stats.txt in the project folder.
Final Project Hotel Reservation System
For your final project, you will be creating a program that interacts with the user to add and review hotel reservations.
Design
For this project, you will need to design and implement the following classes (at a minimum):
Reservation Class:
The class should store the first name, last name, number of night and daily rate for a hotel reservation.
The class should provide the following methods:
print: Returns a String that contains the information in the reservation
getTotalCost: This method multiplies the daily rate by the # of nights and returns the total price
ReservationSystem Class:
The class should store an array of Reservations.
The next available reservation ID (nextID)
The class should provide the following methods:
addReservation: Takes as input last name, first name, ID, # of nights, and daily rate and creates aReservation with this information. Add the reservation to the array of reservations. If the ID of the reservation is larger than the next available reservation ID (nextID), it updates nextID to be 1 more than the ID it just read in.
addReservation: Prompts the user for the info needed to make a new reservation. Add the reservation to the array of reservations. Assign the next ID
findReservation: find a reservation by ID and return it
findReservation: find a reservation by first and last name and return 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 array. Uses the addReservation method for help.
downloadReservations: asks the user for a file and writes the reservations to the file. Use the print method provided by Reservation
updateReservation: asks the user for the ID of the reservation to update and then asks for the data to be updated and updates the reservation
getTotalCost: Calls getTotalCost 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.
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
Prompt the user for the file that contains the reservations.
Read in the records into the ReservationSystem.
Note: You can assume that the file will NOT contain more than 100 records.
Input File Format:
ReservationID LastName FirstName Nights DailyRate
Sample Input File:
1 Bob Mike 2 140.23
2 Matt Benjamin 4 90.00
3 Keller Helen 1 98.10
4 Tim Mary 3 23.10
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. The method will assign a unique id to the reservation using the nextID stored inReservationSystem.
Option 3: Update Reservation
When this option is selected, the program will ask for the ID of the reservation and prompt the user for the new name, # of nights and daily rate. 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:
ID: 1, Name: Mike Bob, Nights: 2, Daily Rate: 140.23
ID: 2, Name: Benjamin Matt, Nights: 4, Daily Rate: 90.00
ID: 3, Name: Helen Keller, Nights: 1, Daily Rate: 98.10
ID: 4, Name: Mary Tim, Nights: 3, Daily Rate: 23.10
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)
Longest stay
Total cost of reservations use the getTotalCost method in the ReservationSystem class
The statistics file will have the same name as the input file (from option 1) but with _stats.txt appended 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.
What to Hand in:
a zip file containing your javadocs, your java files as well as the statistics file and a screen shot of running your program using the following sequence of steps:
Option 1 to add customers from reservations.txt provided with this project
Option 4 to view reservations
Option 2 to add a new reservation
Option 2 to add a new reservation
Option 4 to view reservations confirm the 2 reservations you added are there
Option 3 to update a reservation
Option 4 to view reservations confirm the update happened correctly
Option 5 to find a reservation that exists
Option 5 to find a reservation that does not exist
Option 6 to download the statistics file
Option 7 to exit
Reservations.txt
1 Bob Mike 3 140.23 2 Matt Benjamin 4 90 3 Keller Helen 8 98.15 4 Tim Mary 4 23.1 5 James Alan 3 47.77 6 William Carla 6 94.92 7 Mathew Robin 7 53.7 8 Jacob Tom 6 79.98 9 Nathan Norman 9 230.1 10 Nick Nate 8 537 11 Ethan Mary 6 87.9 12 Kate Helen 2 20.8 13 Benjamin Alan 4 90.44 14 John Jamie 2 89.88 15 Bob Annie 3 100
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