Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Reservation.java Reservation Driver.java Hotel.java Hotel.txt You will write a program that will simulate the reservations of a hotel. You will first need to write the

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Reservation.java Reservation Driver.java Hotel.java Hotel.txt You will write a program that will simulate the reservations of a hotel. You will first need to write the Reservation class. The Reservation class is a simple object class that will hold a guest's name and the room number the guest will be staying in. It should have one constructor that receives a String for a name and an int for a room number. It should the appropriate assessors and modifiers. It should have a toString and an equals method. You, also, need to write a Hotel class. The Hotel class will hold an array of Reservation for the Reservations being held at the hotel and an ArrayList of String for the names on the wait list. There will be one constructor which will receive a number indicating the number of rooms that are in the hotel. The room numbers will be 0, 1, 2, 3, ..., N-1. Such that a person may get assigned to room 0 and that the last room of the hotel with N rooms would be listed as N-1. Among the methods to be found in Hotel class there will be: The method getHotelSize which will return the number of total rooms in the hotel. The method getReservation which will receive an int representing the room and would return the Reservation for that room if one exist, and would return null if a reservation does not exist. The method request Room which will receive a name of a potential guest. If there is room available, then a reservation would be made for the guest in the first available room and that reservation would be returned by the method. If there is no room, the guest would be added to the back of the waiting list and null would be returned as no reservation was made. The boolean method isReserved which will receive a name of the guest and would return if there is a reservation for that guest. The overloaded boolean method isReserved which will receive a room number and would return if there is a reservation for that room number The method cancelAnd Reassign which will receive a Reservation. The method would find that reservation, if it exist, and then remove that reservation from the array. If there is someone on the wait The method cancelAndreassign which will receive a Reservation. The method would find that reservation, if it exist, and then remove that reservation from the array. If there is someone on the wait list, the first person on the wait list would be given a Reservation in the room that just opened up and removed from the wait list. The method would return the new reservation or null depending on what occurred. The toString method which would return all Reservations, one reservation per line, without returning any nulls. Finally, you will write the Reservation Driver class which is where the main method will be located. In there would will read from a file called Hotel.txt. The first value of Hotel.txt will be the size of the hotel. the second value will be the number of guests asking for reservations. After these two integers are written, you will need to pick up the trailing carridge return as all the name of guests will be full names. Read in each guest and attempt to give them Reservations into your hotel. Once all guest are read in, print out all the hotel reservations followed by the wait list. The next value read in from Hotel.txt is the number of cancelations followed by an int for the Random seed. Instantion the Random class with that seed and randomly choose reservations that are being cancelled. Once all reservations are cancelled then print out the Reservations followed by the wait list. It is possible that there is no one in the wait list, however you would still print the wait list header. SAMPLE TEXTFILE 5 5 SAMPLE TEXTFILE 5 10 Marilyn Monroe Abraham Lincoln Mother Teresa John F. Kennedy Martin Luther King Nelson Mandela Queen Elizabeth II Winston Churchill Donald Trump Bill Gates 4 2019 SAMPLE OUTPUT Current Reservations: 0--Marilyn Monroe 1--Abraham Lincoln 2--Mother Teresa 3--John F. Kennedy 4--Martin Luther King Wait List: Nelson Mandela Queen Elizabeth II Winston Churchill Donald Trump Bill Gates Current Reservations: 0--Winston Churchill 1--Donald Trump 2--Mother Teresa 3--John F. Kennedy 4--Martin Luther King Wait List: 2019 SAMPLE OUTPUT Current Reservations: 0--Marilyn Monroe 1--Abraham Lincoln 2--Mother Teresa 3--John F. Kennedy 4--Martin Luther King Wait List: Nelson Mandela Queen Elizabeth II Winston Churchill Donald Trump Bill Gates Current Reservations: 0--Winston Churchill 1--Donald Trump 2--Mother Teresa 3--John F. Kennedy 4 --Martin Luther King Wait List: Bill Gates Reservation.java Reservation Driver.java Hotel.java Hotel.txt You will write a program that will simulate the reservations of a hotel. You will first need to write the Reservation class. The Reservation class is a simple object class that will hold a guest's name and the room number the guest will be staying in. It should have one constructor that receives a String for a name and an int for a room number. It should the appropriate assessors and modifiers. It should have a toString and an equals method. You, also, need to write a Hotel class. The Hotel class will hold an array of Reservation for the Reservations being held at the hotel and an ArrayList of String for the names on the wait list. There will be one constructor which will receive a number indicating the number of rooms that are in the hotel. The room numbers will be 0, 1, 2, 3, ..., N-1. Such that a person may get assigned to room 0 and that the last room of the hotel with N rooms would be listed as N-1. Among the methods to be found in Hotel class there will be: The method getHotelSize which will return the number of total rooms in the hotel. The method getReservation which will receive an int representing the room and would return the Reservation for that room if one exist, and would return null if a reservation does not exist. The method request Room which will receive a name of a potential guest. If there is room available, then a reservation would be made for the guest in the first available room and that reservation would be returned by the method. If there is no room, the guest would be added to the back of the waiting list and null would be returned as no reservation was made. The boolean method isReserved which will receive a name of the guest and would return if there is a reservation for that guest. The overloaded boolean method isReserved which will receive a room number and would return if there is a reservation for that room number The method cancelAnd Reassign which will receive a Reservation. The method would find that reservation, if it exist, and then remove that reservation from the array. If there is someone on the wait The method cancelAndreassign which will receive a Reservation. The method would find that reservation, if it exist, and then remove that reservation from the array. If there is someone on the wait list, the first person on the wait list would be given a Reservation in the room that just opened up and removed from the wait list. The method would return the new reservation or null depending on what occurred. The toString method which would return all Reservations, one reservation per line, without returning any nulls. Finally, you will write the Reservation Driver class which is where the main method will be located. In there would will read from a file called Hotel.txt. The first value of Hotel.txt will be the size of the hotel. the second value will be the number of guests asking for reservations. After these two integers are written, you will need to pick up the trailing carridge return as all the name of guests will be full names. Read in each guest and attempt to give them Reservations into your hotel. Once all guest are read in, print out all the hotel reservations followed by the wait list. The next value read in from Hotel.txt is the number of cancelations followed by an int for the Random seed. Instantion the Random class with that seed and randomly choose reservations that are being cancelled. Once all reservations are cancelled then print out the Reservations followed by the wait list. It is possible that there is no one in the wait list, however you would still print the wait list header. SAMPLE TEXTFILE 5 5 SAMPLE TEXTFILE 5 10 Marilyn Monroe Abraham Lincoln Mother Teresa John F. Kennedy Martin Luther King Nelson Mandela Queen Elizabeth II Winston Churchill Donald Trump Bill Gates 4 2019 SAMPLE OUTPUT Current Reservations: 0--Marilyn Monroe 1--Abraham Lincoln 2--Mother Teresa 3--John F. Kennedy 4--Martin Luther King Wait List: Nelson Mandela Queen Elizabeth II Winston Churchill Donald Trump Bill Gates Current Reservations: 0--Winston Churchill 1--Donald Trump 2--Mother Teresa 3--John F. Kennedy 4--Martin Luther King Wait List: 2019 SAMPLE OUTPUT Current Reservations: 0--Marilyn Monroe 1--Abraham Lincoln 2--Mother Teresa 3--John F. Kennedy 4--Martin Luther King Wait List: Nelson Mandela Queen Elizabeth II Winston Churchill Donald Trump Bill Gates Current Reservations: 0--Winston Churchill 1--Donald Trump 2--Mother Teresa 3--John F. Kennedy 4 --Martin Luther King Wait List: Bill Gates

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Principles Programming And Performance

Authors: Patrick O'Neil

1st Edition

1558603921, 978-1558603929

More Books

Students also viewed these Databases questions