15-200 staff-200@cs Highlights
(Lab #2)


Thursday, September 5, 2002

Question:

We're having trouble getting started with the lab today. What exactly needs to be done to the reservation class? And do the methods in the hotel class require references to the reservation class? My 100 class didn't do vectors at all last year, and Tak hasn't done programming in a while so things are a little fuzzy. We're just looking for some tips to get started.

Answer:

We've provided the skeleton for the reservation class -- but all of the methods are actually empty. You need to finish the implementation of each method so that it satisfies the purpose described in the comments.

The Hotel class contains a Vector. Each element of this Vector represents a different room. Since this is a Reservation system, the only information with which we are concerned is the Reservation information.

So, this Vector will store the Reservation for each room.

I'll post some notes on Vectors, as part of today's class notes, today or tomorrow. In the meantime, check out Appendix A of your textbook, the lecture notes from prior semesters, or the API documentation.


Question:

We're working on this lab and we're decomposing the application as a whole. The problem we're having is that we don't really understand what the reservation class does. It seems like the reservation class stores the reservations -- but isn't the hotel class the one with the vector? Maybe then the reservation class reads the info from the user, sets it as a reservation and passes it to the hotel class -- but then do we even need a separate class for that?

This is what we're thinking:

  • Simulation class gives menu to user (user input/output)
  • Hotel class makes, cancels, prints reservations, and stores that information
  • Reservation class ???

Answer:

The Reservation class models a reservation -- the binding between a person's name (a String) and a room (a number).

The Vector contained within the Hotel class contains one entry per room. Since we are only concerned with Reservations, and not for example, a furniture inventory, we store a reference to a Reservation in each element of the array, or a "null" reference, if the room is unreserved.


Saturday, September 7, 2002

Question:

For Lab 2, do we need to (or can we) edit/change the Simulation class provided to us? Are we not allowed to change any of the code in it?

Answer:

Feel free to edit it if you like, document changes that you make though is there something missing? do you want to hard code some test cases?


Question:

For the Hotel file, after the vector rooms is created, do we add Reservation objects , room numbers( in the form of Integer objects) or peoples' names? (strings) Also do we add in the room numbers ourselves or do can we create a file of rooms and feed that in? (like a .txt file)

Answer:

Please add reservation objects to the Hotel's Vector. The Vector models the Hotel rooms and the only property wee need to maintain is the Reservation information.


Sunday, September 8, 2002

Question:

Can it be assumed that the user won't type in a letter when requesting a room number? or do we need to deal with that scenario?

Answer:

The Sim class already handles this, so you don't have to. Woo hoo!


Question:

Can it be assumed that multiple entries of the same name are not entered in to the Vector rooms? (i.e. there are not 2 different people named "David" with reservations)? or does it even matter if this is the case?

Answer:

David could reserve two different rooms, that's fine. Be sure that when David cancels, both rooms get cleared.


Question:

Can it be assumed that the user won't select the "reserveN" command and then request a room number that is greater than [rooms.size() - 1 ]?

For example, say there are 5 rooms (rooms.size() is 5) and the 5 rooms are numbered 0,1,2,3,4, then can it be assumed that the user won't ask to reserve room # 5?

Should we assume that the user (which would be like the hotel manager) would know how many rooms are reserved/vacant (by printing out the reservations) and logically would *first* build more rooms, if a customer wants to reserve a room # that is higher than the room #s that already exist?

Should we insert code into the reserveRoom(String person, int roomNum) method that prevents this exception from happening (i.e. call the buildRooms(int Num) method if a higher room # is requested?)

Answer:

Of course not, people are always trying to cheat the system and you can bet they'll try to give you bad room numbers! There is already a way of handling errors, namely returning false. You should not build more rooms.


Question:

Is it okay to resubmit updated assignments multiple times as long as we do it before the due date/time?

Answer:

Yup, that'll be fine. but please only put source files in there.


Question:

I was just wondering what time on tuesday the program is going to be due, is it midnight or before class or anytime?

Answer:

The lab is due at 11:59pm on Tuesday.


Question:

We presumed that it should be done in the hotel class in reserveroom method where only name of person is given so should we create a counter and make the different room numbers

Answer:

When you call the version of reserveRoom() that has only one paramter, the name, you may assign the room number any way you'd like -- just so long as the room isn't already occupied (people don't like sharing their beds, well, with those other than of their own choice).

So, whatever you might need to do this should be contained within the Hotel class.


Question:

How do you link the name of the person with the room number?

Answer:

This is the role of the Reservation class. It models this pairing


Question:

How doese one keep track of reservation number in order to delete So if use sends information to cancel reservation will he give his name and room number then you search for it in the vector class and delete it or you keep and reservation number with each new reservation recieve that from the user and then delete the corresponding vector cell

Answer:

The reservations are organized by the Vector within the Hotel class.

If you take a look at the Hotel class, the only cancelReservation() method takes the name of the user and walks through the Vector, cancelling all reservation for this person.

You might find it helpful to take a look at the provided class skeletons. These contain all of the method prototypes and comments describing their function.