More practice for the final

At least one problem on the final exam will ask you to write a program that makes use of several simple classes. The problem in this week's lab exercise is a final exam problem from a previous iteration of this course.

The problem

A local hotel has hired you to write a program to manage reservations for their conference rooms. The hotel has a set of conference rooms with the following names and capacities:

Room NameCapacity
Grand ballroom50
Oneida room30
Michigan room20
Mendota room20
Sunrise room12

Each day the hotel has to make room reservations for these conference rooms. The input to this process is a list of requests, listed in the order that the requests arrive. Each request takes the following form:

<request number> <customer number> <group size> <start time> <duration>

The start times of events are integer hours in 24 hour format. For example, an event starting at 3 PM would be listed as starting at hour 15. Here is a more detailed description of each of these line items.

ItemDescription
request numberUnique identifying number assigned to a request - integer
customer numberUnique identifying number assigned to a customer - integer
group sizeNumber of people in the group - integer
start timeStart hour of the event in 24 hour format - integer
durationDuration of the event in hours - integer

The program will read in a text file containing a list of these requests for a given day and construct a schedule of events for the rooms for that day. Requests are handled in a first come, first serve order. In each case the program should try to put the group into the smallest available room that will accomodate the group. If no room is available for a given request, the program should print an error message saying that request <request number> can not be scheduled. After scheduling all of the requests, the program should print a schedule of events for the day. The schedule will be organized by room and will show the list of events scheduled for each room sorted in order of increasing start time.

Your program should make use of three classes, a Hotel class that represents a collection of meeting rooms, a Room class that represents a meeting room, and an Event class that represents an event scheduled in a meeting room. Room objects should have a name and a capacity, and should contain a list of events. Events should have a request number, a customer number, group size, a start time, and a duration. The Room class should contain a method

public boolean canSchedule(Event e)

that returns true if the room can accomodate a particular event. The Event class should have a method

public boolean intersects(Event other)

which returns true if the given Event overlaps in time with the Event object other. The Hotel class should contain a main method the implements the scheduling program.

Here is a test data file for you to use. Given the following input file

6027 65 33 19 4
6028 5 29 16 4
6029 95 20 8 5
6030 39 26 16 3
6031 25 6 20 3
6032 68 24 7 6
6033 43 5 15 5
6035 90 11 20 3
6036 56 8 20 3
6037 9 14 18 4
6038 36 23 9 2
6040 27 27 15 2
6041 25 38 15 2
6042 85 10 8 4
6043 33 21 7 1
6044 68 22 9 1
6045 69 18 14 2
6046 59 6 13 5
6047 27 31 17 2
6048 89 13 13 1
6049 2 28 12 2
6050 9 30 15 3

your program should produce this output:

Can not schedule event number 6037
Can not schedule event number 6040
Can not schedule event number 6041
Can not schedule event number 6044
Can not schedule event number 6047
Can not schedule event number 6050

Sunrise room:
6042:8-12
6033:15-20
6031:20-23
Mendota room:
6029:8-13
6048:13-14
6045:14-16
6035:20-23
Michigan room:
6046:13-18
6036:20-23
Oneida room:
6032:7-13
6028:16-20
Grand ballroom:
6043:7-8
6038:9-11
6049:12-14
6030:16-19
6027:19-23