This project is a short and sweet project to give you some practice with strings and with building on previous code.
You will build on either the tables.c program from your lab06 or your project 2. You will add three options for servers:
If you were successful at least up through stage 4 of project 2, then build on project 2. That will allow you to earn up to 100% of the points for project 3.
If you had significant difficulty with project 2, and want a fresh start, you may build on lab06 instead. That will only allow you to earn up to 90% of the points for project 3, but it will be an easier task, since you won't have to make the new A, N and F options interact with the tableCapacities array.
A note for those who included merge/unmerge in Project 2: It is acceptable to build on a project 2 that is complete only up through stage 4; it is not necessary to include the merge/unmerge option in your project 3. (Note that if you do include it, it should interact successfully with the new N and F options, and there is no extra credit for including it, so you are strongly encouraged to work from your Stage 4 "snapshot" from Project 2.)
See the project two description for details about how to work in stages. Several students ignored this advice duirng project 2 and discovered (the hard way) why they should have followed it.
into a file called proj3.c in this directory. This file is your starting point for project 3.
In this stage you'll add a feature that allows the manager to keep track of a number of servers (waiters and/or waitresses), and which table each one is assigned to. Each table will be assigned a server. An array called tableToServer will "map" table number to server number; that is, the index of the array will be the table number, and the value in the array will be the server number.
Here are step-by-step instructions:
> ./proj2
> ./proj2 2
> ./proj2 6 HarveysDiner.dat
> ./proj2 2 HarveysDiner.dat
> ./proj2 3 ChezPhillipe.dat
The first line indicates that the default table capacities and the default number of servers (4) should be used. The second line indicates that you are using 2 servers instead of 4 (and if building on project 2, the default table capacities of 2, 2, 4, 4, 6, 6 should be used for 6 tables.) The remaining command lines are appropriate for building on project 2, and indicate both the number of servers, and the name of the file to take the table capacities from.
Then, add an "A" option into the program to "assign" servers
to tables. That A option should cycle through all the tables starting with
table
0, up to the end, and for each table, print out:
For tables where there are guests, just print the information, and move on to the next table (it's bad form to change the server at a table that already has guests at it; typically this is not done.)
If no server is assigned yet, don't print "server=-1;" instead print a message such as "no server assigned".
Do permit the manager to enter -1 to indicate that a table has no server assigned. (That allows the manager to put a table out of service, if, for example, there is a leaky roof or some other problem that makes a certain table unusable).
After each change that is made, echo the "new" information back to the user (e.g. print out table number, capacity, number of guests and the new server). It would be appropriate to create a function to print out this information, and call it whenever you need to print out those values.
Now add an option that permits the manager to assign names to each server. That is, the manager can enter information that identifies that server 0 is "John", server 1 is "Mary", etc.
You will add an array such as the following:
#define SERVER_NAME_MAX 20
char serverNames[10][SERVER_NAME_MAX];
In my example code above, I used "10", but this is just to illustrate the idea: you should actually use the #define that you created in the previous stage that indicates the maximum number of servers.
This declaration of serverNames indicates that is is an array that can hold up to 10 strings, each of which can be up to 19 characters in length (remember one extra char is needed for the '\0').
The N option will ask the user of the program to enter a server number. If the server number entered is -1, the N option is finished, and you go back to the main menu. Otherwise, if the server number is in the valid range (0 to 9), the program prompts for the server name. If the server number is outside the valid range, and isn't -1, print an error message, and prompt the user again for the server number.
Initially, each server name should be the empty string (i.e. "").
Now, modify the P option: When you are finished adding the N option, modify the P option so that it prints the server name for each table in addition to the server number, table number, and current number of guests (and, if building on project 2, the table capacity as well.) If you used a function to print out each line of "table information", then adding the printing of "server name" into the function makes it work with the A option as well (a nice plus!).
Now, add a new option F that allows a customer to specifiy the name of their favorite server and size of their party. The F option will search through the list of tables for either the first fit or best fit table that has that server, will fit their party, and is available, and will assign the party to that table. If no such table is available, the F option will indicate this, and go back to the main menu.
As in Project 2, the choice to do first-fit, or best-fit is up to you (see project 2 for more description of the two options.) However, you'll earn 5 more points for doing best-fit (which is only slightly harder) vs. doing first fit (which is only slightly easier), so try to use a "best fit" approach.
You need to create a script called "proj2.txt" showing that all of the features of your program work correctly. As with project 2, you are not required to "turn in" a formal test plan, however you should think through a test plan before you script your project, and most likely, you should write this test plan down before you start your script.
Your testing needs to be as complete as possible, covering both legal and illegal inputs. If your program is capable of performing an action, your test plan should cover that action. if your program is capable of detecting an error condition and printing an appropriate message, your test plan should include those cases as well.
As always, your script should include a listing of your program, a listing of each input file that you use, followed by a clean compile, and your sample runs. Putting the items in that specific order will make it easier for your TA to grade your project. Making things easier for your TA tends to result in higher marks.
Review the style issues from project 2 regarding programmer-defined global variables, and full function prototypes, and make sure you follow those guidelines for this project as well. Also review the rubrics on your TAs web site to familiarize yourself with other style issues that he/she is emphasizing.
The following table indicates, in general, the amount of credit assigned to each portion of the assignment. Your TA might (at his/her discretion, and under supervision of the instructor) further refine each of these items into a more detailed grading rubric. Consult with your TA for more details.
Also note that while 20 points are assigned "overall" to "following instructions" and "coding style", the TAs have the discretion to deduct additional points from the individual portions of the assignment for these issues as appropriate. Deductions may also be made from individual portions of the assignment for "incomplete testing".
| Stage | Explanation | Percent | Cumulative Total |
| All | Following submission instructions | 10 | 10 |
| All | Overall coding style | 10 | 20 |
| All | Building on project 2 rather than lab06 (i.e. making all new options interact correctly with the table capacities features introduced in project 2) | 10 | 30 |
| 2 | Adding the A option to indicate server numbers. | 10 | 50 |
| Adding server numbers to output of P option | 5 | 55 | |
| Modifying the S and R options to only assign tables that have been assigned server numbers. | 10 | 65 | |
| 3 | Adding the N option for adding server names to the program. | 10 | 75 |
| Adding names into the P option | 5 | 80 | |
| 4 | Adding the F option for choosing favorite server by name. | 20 | 100 |
| Note: 5 out of the 20 points are reserved for making your F option pick the "best" fit and not the "first fit" table for the favorite server indicated. | |||
Penalties (this penalty are like a "tax" applied to your grade after deductions taken above)
Credits: Professors Terry Harvey and Phill Conrad contributed text to the description above, and collaborated on the source code provided. Some of the ideas for features were contributed by CISC105 students from Fall 2004 as part of their lab06 submissions. TA Sara Sprenkle also made many helpful suggestions.
*** end of project 3 description ***