Welcome to the one-of-a-kind "All-or-Nothing-Restaurant", where if guests are lucky enough to get seated, then they can eat as much as they want. But, there's a catch. The arriving group can only be seated all together at one table. If the current seating arrangement cannot accommodate them, they need to try coming back another night. Each table in the restaurant can only be used once in the entire evening.
Given the restaurant's popularity, there is large queue of groups waiting to be seated everyday. The restaurant however only has 3 types of tables - Large (which can accommodate 10 guests, Medium which can accommodate 7 guests and Small which can accommodate 5 guests). Currently, the restaurant has only 1 Large sized table, 2 Medium sized tables and 3 small sized tables. The owner of the restaurant has hired you to write a program to assign guests to tables.
The input of the program consists of the size of the groups, in the order in which they appear in the queue. The size of the first group to be seated appears first. The table assignment program must first print a list of available tables in the restaurant. It should then read the sizes of each group to be seated and report on attempts to assign the group to a table. Finally, it should print a summary of seat assignments. See the example input and output files for details. If a group size is not valid (i.e. not a positive number) an exception should be thrown and an error message printed before the program proceeds with the next group.
The program assigntables.cpp is provided, together with the header files Restaurant.h and Table.h . You should not modify these files. You will implement the classes Restaurant and Table in the files Restaurant.cpp and Table.cpp respectively. You will create a Makefile that includes a target assigntables (that builds the executable) and a target clean (that removes the executable and all object files). Use the test input files to verify that your program reproduces exactly the example output files. Use the Unix diff command to compare your output to the example output.
The Restaurant class constructor creates the list of tables using dynamic allocation of the (private) pointer array tableList. The tables should appear in the list in order of decreasing size. The Restaurant constructor takes three arguments (the number of large, medium and small tables in the restaurant). The size data member is the total number of tables in the restaurant. The Restaurant class has a member function addGuests that tries to assign a group of guests to a table by inspecting the list of tables and by assigning the group to the first table that can accommodate the group, starting at the beginning of the tableList array. The Restaurant class also has a member function printSummary that prints a list of tables with their current and maximum occupancy. Empty tables should not be printed in the summary. See the examples of output files for details on the output format.
The Table class constructor takes one argument (the size of the table). It has accessor member functions maxOccupancy and currentOccupancy returning the maximum and current number of guests respectively. The addGuests member function attempts to add a group of guests to the table and modifies the occupancy accordingly. It returns true if the operation is successful and false otherwise.
All compilations should complete without warnings (use the -Wall option).