Project 3 notes, CISC105, Fall 2004

Here are some notes on project 3 that were too late to include in the proj3.html file. I may add to these as additional questions arise

  1. In the option to assign servers to tables, the instructions say to loop through ALL the tables.

    Another possibility is to prompt the user for table number, and allow the user to enter a server for only that table. You could then return immediately to the main menu, or allow the user to enter another table number, perhaps entering some sentinel value such as -1 when the user is finished assigning servers.

    Usually, I'm a stickler for following instructions, but on this point, I'm going to give you discretion to implement it however it seems best to you. As long as it is possible for the manager to assign servers to each table in some fashion, how you do it is up to you.

  2. There was a typo in the proj3.html file that had identical descriptions in the summary of the A and N options (though the details were correct.) That has been fixed now.
  3. The array of server names is declared like this:
    #define SERVER_NAME_MAX 20
    
    char serverNames[10][SERVER_NAME_MAX];
    
    (though you'll need to use a #define instead of the number 10).

    When you pass that array into functions, you pass it just with the array name, just like singly-subscripted arrays.

    However, the function prototypes look a bit different. For example, a function prototype for a function that takes the tables array, and the tableToServer array might look like this:

    void myLovelyFunction(int tables[], int tableToServer[], int numTables);
    
    If you are also passing in the serverNames, you'll need to pass that in like this:
    void anotherLovelyFunction(int tables[], int tableToServer[], 
                               char serverNames[][SERVER_NAME_MAX],
                               int numTables);
    
    You'll get an error if you try to do it this way, because when you pass an array with multiple subscripts, only the first one may be left empty:
    void aNotSoLovelyFunction(int tables[], int tableToServer[], 
                               char serverNames[][], /* illegal */
                               int numTables);
    
  4. If you are building on lab 6:

    The instructions indicate that you should have only one command line parameter, one that indicates the number of servers. Since you also need to know the number of tables, this will imply that the number of tables is fixed, and the capacity of each table is fixed. You can use the values that were defined in the sample code for lab06, namely:

    #define NUM_TABLES 6 /*  number of tables */
    #define GUEST_MAX 4  /*  maximum guests per table */
    
    This means that the number of tables that "exist" in the restaurant and the number of tables in the array is the same.

    Therefore, there is no need to use the -2 value (the one that marks tables that are in the array, but that do not exist in the restaurant); that only makes sense when you can have a variable number of tables, as was the case with project 2.

    However, you will still have to work with the -1 value; you'll initialize all elements of the tableToServer array to -1 near the start of the program. This will indicate that the tables have not yet been assigned any server.


Phillip T Conrad
Last modified: Mon Dec 6 11:18:10 EST 2004