I have a task to develop an online booking system. If the user can enter the zip code / no people / time of booking and get a list of restaurants. Assumption (User and restaurant are always in the same city)
Each restaurant may have several tables with a different number of seats. So, 2 tables that accommodate 4 people and 4 tables that hold 4 people.
I am having problems with the correct data structures.
My classes are as follows
Restaurant : contains opening time, timeOfClosing, totalNoOfSeatsAvailable Not sure how I will store information in a table in a restaurant. It does not make sense to have a separate class for the table. All I need is howManytables for free and what are their sizes.
Reservation This saves the actual reservation and allows you to cancel the reservation.
Backup system : contains an interface for "List checkAvailability (long time, int people)" How will this return this list? Initially, I was thinking about using Queue priority to maintain a queue with as many places as possible. But then I will look through this list to see if the time is right to make a reservation, and then after the reservation is made, refresh this queue. One of the problems is that the queue makes all duplicates.
My specific questions are:
- How to store information in a table in each restaurant.
- What is the best way to keep this list of restaurants so that I can return the list without having to sort this information every time.
EDIT: Asked how to store information in a table. My special thing is that saving the table class means that I create unnecessary objects. Here are my thoughts. 5 tables in which 2 people are placed have the same objects - I mean that there is no important information that will differ from them. I just need numbers. no seats / table. (If I have a table of 4, but 3 people, I will consider this table)
I was thinking about creating 3 arrays. Suppose the table represents 1,2, etc., therefore int [] differentSeatingOnTable; its indexes are tables, and values ββare allowed places. Then an array of tables with totalNoOfThosetable, where indexes are tables and values, are the total number of such a table. Similary for free tables freeTables, where the index is a table and how much of such a free table is left.