-
Hotel Booking system
I am trying to create a ms-dos hotel booking system for college.
It is just an exercise.
I need to mimic checking for room availability. If a certain room is booked for a certain date I need to know.
I am having trouble thinking of the best way to cross reference dates and rooms.
A 3d array? month, date, room?
Seems like the array will get really big
Anybody got any tips on how to structure this...
-
objects
one way you could do it is create a Class, eg 'Accomodation'
give it attributes required, like
bool is_booked
string date_from
string date_to
then declare an array of objects for this class, eg
Accomodation room[100]
-
So if I use malloc/realloc I can make that dynamic?
rather then a static [100]
Then I can search by date first, then, if any dates overlap, check each object by room
Code:
For(amount of accomodation objects)
if (dates overlap)
if (room booked)
invalid booking
end
end
else
rooms are bookable, make booking (booking constructor)
end
that should work.. seems a lot more efficient on memory.
Thanks rogster
-
yes but the thing is, in terms of modelling a hotel normally has a fixed number of rooms, and isnt that the point you need...that you want to check the register (read 'the properties of room object' ) of rooms and see if they are available or not, so the room must already be constructed to do that anway..?