Lab 2 - Hotel Reservations
Due: Monday, January 30, 2006 at 11:59pm

Introduction

Your task this week is to implement a simple hotel reservation system. This system will allow customers to request any available room, request a specific room, and cancel reservations.

Since the staff is optimistic about future economic growth the reservation system also has to accomodate the growth of the hotel. In other words, the proprieter should be able to add additional rooms without disturbing exisitng reservations.

The Reservation class

The Reservation class is a simple class that models customer reservations, including the customer's name and the room number. As you might expect, the Reservation class provides some simple methods for maintaining an individual reservation.

Please consult the comments in the class skeleton for the details of each method's paramters and behaviors. Please also note that you may or may not actually use all of the methods of this class in your implementation of the reservation system, but should implement and test them, anyway.

The Hotel class

The Hotel class models the hotel as a collection of rooms, each of which is represented as a Reservation, either actual, or null.

To maintain the Reservations associated with each room, the Hotel class will contain a ArrayList. If you don't remember ArrayLists from your prior course, please don't worry. They are a very simple indexed collection, much like an Array. They have a much richer collection of behaviors. Among their additional capabilities is their ability to grow on the fly.

Be sure to familiarize yourself with the ArrayList API before beginning. Please pay close attention to the difference between the size() and capacity() methods.

You will need to complete the following methods of the Hotel class. For more detail, please see the comments within the skeleton.

The Simulation Class

This class contains the main() method for the simulation. It creates a new Hotel and provides a menu system and work loop that yield a very simple reservation system. If you give careful thought to your test cases, this system will allow you to test your implementation of the other classes.

As before, more detail is provided by the comments within the Simulation class. But, this time you should not be concerned with every detail. For example, we don't expect that you'll remember how Java I/O works. At this point, it is okay if you just accept that this piece of the code works as intended.

Plan of attack

  1. Complete the Reservation class.
  2. Review how ArrayLists work: Java API
  3. Complete the Hotel class as indicated above.
  4. Test the entire project extremely thoroughly (we will!)

Skeleton Files

One Important Note

Within the provided code, notice the loop to add the "null" references. This ensures that the "size" is sufficient for the set() method to work. If this doesn't make sense, please check the Java API documentation, and then -- with us.

Submission