Shane Shane - 2 months ago 16
Java Question

Design problems: Reservation system

I have to design and implement a reservation system for a hotel. I have

  • an array list of Reservation objects

  • an array list of room objects

I want to 'reserve' the room at a given date.

To book a room without a date would be easy but its the date part that's complicating it. I'm struggling with the design of this and confident with a nudge in the right direction I could code it.

How do you say that a room is booked at this date but not at that date?

There is no database or anything its just an abstracted reservation system.

(I've been staring at this for a while, forgive me if if the solution is easy)



EDIT -- on second thought, why not just let each Room have a list of Reservation instances, which in turn have start/end properties that tell you when the reservation occurs?

That way, to tell if a room has a reservation for a certain time, you just loop thru the reservations for the room and see if the time in question is within the start/end range of any of the reservations...granted that code is not too easy (nor too hard) to implement, but that's the basic idea.