I am trying to create a hotel booking system.
Should I use a 2d matrix for rooms
and another matrix for the dates?
A cross reference, or is there a better way
Printable View
I am trying to create a hotel booking system.
Should I use a 2d matrix for rooms
and another matrix for the dates?
A cross reference, or is there a better way
this seems to me essentially to be a database question.
I'm not really seeing a 2d matrix for rooms, which are just a list of room numbers, right? i'd make that field text, however, to allow for the possibility of 102A or something like that.
then the booking would be a 2d matrix with columns of room number (multiple entries possible), arrival date, departure date, occupant name, number of occupants, daily rate, etc. not sure whether it has any advantage at all to create a unique key column here over and above your array index. if it were a database table, i definitely would, but i'm not seeing why you would need it when it's just an array.
otherwise i'm really just building it here using c++ arrays exactly like tables in a database
If the room numbers are all contiguous (eg, 101 - 599) you could use a vector of strings with the dates (just subtract 101 to get the vector[element]). If not, try a STL map of strings. Maybe you want to use some kind of int for the date, it *might* make sorting easier.