Project 2 - Hotel Reservation System

Minimal Submission Due: Sunday, February 12th, 2006

Final Project Due: Sunday, February 26th, 2006

Overview

For this project you will be creating a graphical user interface for a hotel reservation system. The system allows a user to enter a request for a room at the hotel, and then the system checks a database to discover if the request can be accomodated (the room is available). If the room is available for the requested date(s), the user can then confirm the reservation and the database will be updated with the new information. After the reservation is made, the system displays a confirmation message to the user that gives a summary and the total cost of the reservation.

Objectives

Getting Help

You may get help from your instructor(s) and the teaching assistants. Anything else is not allowed and is subject to the penalties listed in the DCS Policy on Academic Dishonesty. This includes but is not limited to:

We certainly do not expect there to be absolutely no communication between the students of this class; we know that people tend to learn very well that way. However, we expect that you will limit your discussion of this project to determining the specification of the problem. If you have any doubt if what you would like to do might violate our rules, please see your lecture instructor for clarification.

Don't forget that the CS tutoring center is available to you.


Program Requirements

The Hotel would like to provide customers with a user-friendly way to make a reservation, and would also like to keep a record of all the reservations made at the Hotel for the year 2006. A graphical user interface (GUI) will be the user-friendly part of the system, and a persistent database (one that saves the data between sessions) will be the record-keeping part of the system. In other words, the GUI acts as the front-end for the system, and the database acts as the back-end.

Important Note: You are not allowed to use any kind of automated GUI code generation tool for this project. Any student who uses a GUI code generator will receive a grade of 0 for this project.

The Hotel

The Hotel has only six rooms - three allow smoking, and the other three do not allow smoking. Of the three smoking or non-smoking rooms, there is one room with a single bed, one with a double bed, and one with a king size bed. The rate per night (smoking or non-smoking) for the three different bed sizes are as follows:

Single Room: $100
Double Room: $125
King Room  : $150

All six rooms are initially available for any night of the year in 2006.

The GUI front end will allow a user to make a reservation based on the user's needs and the availability of a given room. A user can specify what type of room he or she would like, and can find out the availability of that room by selecting the month(s) for which they would like to reserve the room. The system will respond by displaying a calendar of the selected month(s), with each month displayed in a separate window. The days of the month for which the selected room is available will be displayed in green, and the non-available (already reserved) days will be displayed in red. When the user clicks on an available day, that day's color will change from green to yellow. The user may unselect a day by clicking on it again, which will change the color of the day from yellow back to green. The user can select as many days from as many months as he or she would like, as long as the requested room has not already been reserved. When the user has finished selecting days, he or she can reserve the room for the selected days, and a message will be displayed to the user showing the type of room selected, the chosen days, and the total cost. The user then has the option of confirming the reservation, or canceling the reservation. If the user selects confirm, the system asks the user for a first name and a last name, and the database will be updated with the reservation information and the user's first and last name. The updated database will be used to display the availability information for the next user of the system. If the user selects cancel, then no information is saved and the the user has the option of reseting the system to begin anew.

The Hotel Reservation System will be started as follows:

java Hotel filename

The filename argument is required; it is the name of the file containing the reservations that have already been made, one day per line, in the following format:

	month day bedSize smokingChoice firstName lastName

When the program is initially started, filename does not exist - it will be created when the first reservation is confirmed. Every run of the program after the first will concatenate any new reservation data onto the end of the file, given the same filename argument. If a different filename is given as the command line argument, a different database of reservation information will be maintained, i.e., multiple databases do not "know" about one another.

If any errors occur upon system startup, an error message must be printed on standard error and the program halted. If the first or second error occurs, the program shall halt before the GUI starts up. Here is a table of possible error situations and the messages displayed as a consequence.

Fig. 1: Error Situations and Messages
*required for minimum submission

error

message to be displayed (all terminate with a new line)

Illegal number of arguments* Usage: java Hotel filename
File named by second argument cannot be opened. Cannot open file filename.
Improperly formatted data in the file (includes premature end of file) File filename has corrupted contents.

Since this is an event-driven system, rather than a command-line-driven system (as in the last project), most of the error-checking will be taken care of by the event handlers. For example, if the user tries to make a reservation before selecting the date(s), a dialog box should be diplayed requesting that the user select the date(s). Other potential error conditions can occur if the user forgets to select a room type or month before choosing the date(s), or if the user forgets to enter their first name or their last name, or if the user forgets to select at least one day before confirming the reservation.

Example:

Note: Your GUI design may look different from the one shown in this example; that is OK as long as the functionality is the same.

Assume the file hotel-1.1 consists of the following reservation information:

January 1 Single Non-smoking John Doe
January 2 Single Non-smoking John Doe
April 3 Double Smoking Jane Roe
March 30 King Non-smoking Sue Jones
March 15 Double Non-smoking Bill White

Bob Smith would like to make a reservation for March 7th and 8th for a Non-smoking room with a King sized bed. He starts the system up and enters information into the main GUI window:

After selecting the room type and month, he can then choose the specific dates by clicking on "Choose Dates". The following calendar for the month of March will be displayed. (Note that the King non-smoking room has already been reserved for March 30th, so Bob cannot select that date)

As he clicks on "7" and then "8", the colors of those days will be changed to yellow:

Every time Bob clicks on a green cell, the selection (month and day) will be inserted into a temporary collection, and that cell's color will change from green to yellow. If he clicks on a red cell or a gray cell (a non-day) nothing will happen. Clicking on a yellow cell will change that cell back to green and delete the selection from the temporary collection.

When Bob is done selecting days (he can select as many as he chooses from as many months as he wishes), he returns to the main GUI window and clicks on the "Reserve Room" button. This brings up a reservation summary window, where he can enter his name and confirm the reservation, or cancel it:

If he chooses to confirm the reservation, he clicks on that button and gets a confirmation:

At this point, the file hotel-1.1 will be updated as follows:

January 1 Single Non-smoking John Doe
January 2 Single Non-smoking John Doe
April 3 Double Smoking Jane Roe
March 30 King Non-smoking Sue Jones
March 15 Double Non-smoking Bill White
March 7 King Non-smoking Bob Smith
March 8 King Non-smoking Bob Smith

Note that a single confirmation may consist of multiple lines concatenated onto the file - one line per date confirmed. Also note that a single confirmation is always for a specified room type, regardless of how many days are confirmed. Thus, if Bob would like to select a different type of room he must return to the main window and click on the "Reset" button to select another room type.

If another user accesses the system (assuming the same filename) after this update, and requests a Non-smoking room with a King sized bed in the month of March, the following calendar will be displayed:


Project Design

  1. There are two different kinds of design to consider for this project. The first design involves the user interface and the types of GUI widgets that will be presented to the user. Be sure to make your user interface intuitive and easy to understand and use. Try to minimize the textual instructions displayed and eliminate unnecessary widgets. Aim for a "clean" design that takes advantage of the way people are already accustomed to selecting and viewing information.
  2. The second design to consider is the classes that you will develop to implement the project. The main program will be called Hotel.java, and will be responsible for creating and displaying the main window from which other windows may be generated, depending upon the user's selection. You may want to have another class that takes care of creating and displaying a calendar for a given month, one that creates a new reservation, and one that confirms the reservation and writes the data to the file. You may also want to have another class that, given a selected month, determines which day of the week the first day of the month falls on and how many days there are in that month. Since we are only concerned with the months of the year 2006, this information can be "hard-coded" in a month class as constants, and should made easily changeable to accomodate different years in the future.

Project Submission

Minimal Submission

In order to meet minimum submission qualifications you must submit the following:

When you have the classes for the minimal submission working you can submit all your source code using the following command:

try 232-grd project2-min Hotel.java ...

The ellipsis ("...") means that you may submit as many other java files as your design requires.

Final Submission

As stated in the Program Requirements section given above, the final submission will:

When you are satisfied and confident that your project meets final submission standards, submit all your source code using the following command:

try 232-grd project2 Hotel.java ...

$Id$