Wednesday, March 3, 2010

Design a Restaurant reservation system

It's a OO design question where you have to design a Restaurant reservation system. You have to tell about the classes, data members and interfaces and how they will interact with each other.

For these kind of problems - first define all the entities in the ecosystem for this application and the assumptions you are going to make.

Define the problem -
  1. In a restaurant, there are multiple tables with varying seating capacities.
  2. A table of a seating capacity of n can be booked for m people of a group such that m <= n
  3. A table can be re-booked for the same day only if the there is a minimum T duration difference between 2 bookings.
  4. Booking can be done in fixed hours when the restaurant operates.
External interface inputs-
  1. Number of people [input]
  2. Time of booking required [input]
  3. Contact details [input (optional)]
External interface Methods
  1. int CheckTableAvailability(int NumPeople, time_t TimeOfBooking, int *tableNumber, time_t *alternativeTime) - This function will tell whether the booking is possible or not. If possible on the input time it will return 1 and file the tableNumber. If not on the input time, but at some time near to that, it will return 2 with the alternativeTime and TableNumber that can be booked. If not at all possible then it will return 0.
  2. bookTable(contactDetails, tableNumber, time_t TimeOfBooking)
Extra functionality
for CheckTableAvailability , it can also return an array of tableNumber possible for booking. Like some restaurants have different sections (smoking zone, pool side, garden side etc) which will give the customer a choice to make.

Class: Table
{
int TableId;
int SeatingCapacity;
string speciality;
}

Class Booking
{
int bookingId;
int TableId;
time_t startTime;
customerDetails;
}

Class: BookedTables
{
HashTable bookings ( key: timeslot, value: int booked[NumTables] )

3 comments:

  1. I dont think booking and booked tables resemble entity thus classes

    ReplyDelete
  2. I just stumbled upon your article about designing a restaurant reservation system, and I must say, I found it incredibly insightful. Your clear and concise explanations made the complex topic feel much more approachable, even for someone like me who isn't a tech expert.

    Learn more:
    Best Restaurant Operating System
    Best Accounting Software For Restaurants
    Artificial Intelligence In Restaurants
    Best Website Builder For Restaurants
    Call Deflection Solutions
    Restaurant Digital Menu
    Restaurant Scheduling Software
    Restaurant Gift Card System
    Best Restaurant Loyalty Programs

    ReplyDelete