In this assignment, you will implement a prototype system that could serve as the "back-end" of a hotel reservation system (imagine wotif.com). Customers can make, change and cancel bookings. A hotel consists of a set of numbered rooms: each room is either a single, double or triple room (so has capacity 1, 2 or 3). A booking request consists of a request number plus one or more room requests for a number of rooms of a certain type (e.g. two single rooms and one double room) for a period of time given by an arrival date and a number of nights (assume all bookings are for 2015). A request is either granted in full or is completely rejected by the system (a request cannot be partially fulfilled).

Assessment will be based on the design of your program in addition to correctness. You should submit at least a UML class diagram used for the design of your program, i.e. not generated from code afterwards.

All input will be a sequence of lines of the following form, and all hotels will be declared before any commands are issued:

Hotel < name> < roomnumber> < capacity>
# specify that hotel with < name> has a room with number < roomnumber> that has the size < capacity>
Booking < id> < month> < date> < numdays> < type1> < number1> < type2> < number2> . . .
# booking with < id> starting on < month> and < date> for < numdays> of < number1> rooms of < type1>, etc.
Change < id> < month> < date> < numdays> < type1> < number1> < type2> < number2> . . .
# change booking < id> to start on < month> and < date> for < numdays> of < number1> rooms of < type1>, etc.
Cancel < id>
# cancel booking < id> (if it exists) and free up rooms
Print < name>
# print occupancy of each room in the hotel < name>

To remove any ambiguity, booking requests and changes are fulfilled as follows: each hotel is checked (in order of definition in the input file) to determine whether every room request can be satisfied, and if so, the first available rooms (again in order of definition in the input) are assigned to the booking request. The output should list rooms assigned to the booking in order of the declarations at the start of the input file (see first example below). You can assume that each booking request (and similarly for change requests) has at most one room request for a room of a given type (e.g. does not ask for double rooms more than once). Do not try to fulfil requests by allocating double rooms when a single is requested, or by reassigning rooms to different bookings to create vacancies, etc. For printing, output the occupancy of all rooms at the specified hotel in order of room declarations, then date.

Create all your Java source files in the default package. Call your main Java file HotelBookingSystem.java. Read input from a file whose name is passed as an argument to the main method in the call to java HotelBookingSystem and print output to System.out. For machine marking, the output will be redirected to a text file that will be compared to the expected output (so do not print out extra spaces, etc.) and remember to close the file. For simplicity, each hotel name will be just one word. You can also assume that booking ids are unique and that all hotel names are declared at the start of the file. Print out months in the standard three letter format. If a booking request cannot be fulfilled, print out Booking rejected, for a change that cannot be made, Change rejected, and for a cancellation that cannot be done, Cancel rejected.

To read input from a text file (whose name should be passed as a command line argument to java, e.g. java HotelBookingSystem input.txt), use code such as:

Scanner sc = null;
try
{
sc = new Scanner(new FileReader(args[0])); # args[0] is the first command line argument
}
catch (FileNotFoundException e) {}
finally
{
if (sc != null) sc.close();
}

Sample Input

For example, the format and meaning of the input is as follows (comments are for explanation and should not appear in the actual input):

Hotel Surfers 101 2 # Hotel Surfers has room 101 with capacity 2 ("double" room)
Hotel Surfers 102 2 # Hotel Surfers has room 102 with capacity 2 ("double" room)
Hotel Surfers 103 1 # Hotel Surfers has room 103 with capacity 1 ("single" room)
Hotel Burleigh 101 2 # Hotel Burleigh has room 101 with capacity 2 ("double" room)
Booking 1 Jan 25 2 single 1 double 1
# Booking request 1 is for 1 single and 1 double room starting on Jan 25 for 2 nights
# Assign rooms 101 and 103 of Hotel Surfers (output Booking 1 Surfers 101 103)
Booking 2 Jan 24 4 double 1
# Booking request 2 is for 1 double room starting on Jan 24 for 4 nights
# Assign room 102 of Hotel Surfers since room 101 is occupied (output Booking 2 Surfers 102)
Booking 3 Jan 26 1 double 1
# Booking request 3 is for 1 double room starting on Jan 26 for 1 night
# Assign room 101 of Hotel Burleigh (output Booking 3 Burleigh 101)
Change 1 Jan 27 3 single 1
# Change booking 1 to 1 single room starting on Jan 27 for 3 nights
# Deassign rooms 101 and 103 of Hotel Surfers and assign room 103 (output Change 1 Surfers 103)
Booking 4 Jan 25 2 single 1
# Booking request 4 is for 1 single room starting on Jan 25 for 2 nights
# Assign room 103 of Hotel Surfers (output Booking 4 Surfers 103)
Cancel 3
# Cancel booking 3
# Deassign room 101 of Hotel Burleigh (output Cancel 3)
Booking 5 Jan 26 1 single 1
# Booking request 5 is for 1 single room starting on Jan 26 for 1 night
# Request cannot be fulfilled (output Booking rejected)
Print Surfers
# Print out occupancy of all rooms at Hotel Surfers, in order of room declarations, then date

Sample Output

The output corresponding to the above input is as follows:


Booking 1 Surfers 101 103
Booking 2 Surfers 102
Booking 3 Burleigh 101
Change 1 Surfers 103
Booking 4 Surfers 103
Cancel 3
Booking rejected
Surfers 101
Surfers 102 Jan 24 4
Surfers 103 Jan 25 2 Jan 27 3

Design: Adherence to object-oriented design principles, clarity of UML diagrams and conformance to UML diagrams to code Programming style: Adherence to standard Java programming style, understandable class and variable names, adequate Javadoc and comments

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.