Lab07, CISC181, Fall 2004

NOTE: Part of this lab (the test plan part) must be completed IN LAB this week. It is a part of the lab where you may collaborate, but it must be completed IN LAB before you leave lab if you are to be assured of being able to complete the lab on time. If you leave lab without that part done, neither I nor the TAs can be responsible for any delays that may result.

The "tables.cpp" program: working with arrays, cin.getline, menu-driven structure

In the lab07 directory, there is a program called "tables.cpp". Your instructor will review this program in lecture (if he/she hasn't already). A list of items to be reviewed appears in the top of this program.

Look over that list of items, and make sure you are comfortable with each of the items indicated there. If not, ask your instructor or TA any questions you have.

Once you are comfortable with the code that is there, copy the program to a file called "lab07.cpp", and make the following modifications:

  1. Add an option S to "select" a particular table that the customer wants to reserve (instead of just choosing the first available table.
  2. Add an option T to print the total number of guests in the restaurant at any given time.
  3. Add a constant NUM_SERVERS. Assign server numbers 0 through NUM_SERVERS-1. In the output of the P command, in addition to listing the number of guests, indicate which server is serving each of the tables.

    You wil need to devise an algorithm to map the index of the table to a server number with some fixed mapping. For example, if NUM_SERVERS is 3 and NUM_TABLES is 10, the mapping might be, for example, server 0 might have tables 0, 1, 2, server 1 has tables 3, 4, 5, server 2 has tables 6, 7, 8 and 9).

    Note that it is not always possible to divide the tables totally evenly, but you should divide them as evenly as possible. It's not important whether the high or low numbered server gets stuck with the extra tables.

    It is not necessary for the tables for a given server to be consecutive, as long as the tables are evenly divided. Another possible division is that server 0 gets tables 0,3,6,9, server 1 gets tables 1, 4, 7, and server 2 gets tables 2, 5, 8. Each of these divisions suggests a particular implementation; the choice of implementation is up to you.

    You should write a function with the prototype "int tableToServer(int i)" which takes a table number as a parameter, and returns the server number. The function should not depend on any particular values of NUM_TABLES or NUM_SERVERS; it should continue to work even if those numbers are changed, without any further modification to the program.
  4. Add server numbers into the T option.. that is, in addition to adding up the total number of guests, also add up the total number of guests for each server. You may find it convenient to add a second array to the program to accomplish that task.

In future iterations of this program, additional options might include:

What you must do IN LAB before you leave: a test plan

Before scripting your results for this program, write a "test plan". A test plan is a essentially the "users" side of the script, and a rough description of what you expect the results of the program to be. That is, you will essentially write a "mock up" of what you expect the final script file to look like, using the text editor (emacs or vi) to create it. You do not have to produce the output exactly in your mock up; a rough description is enough. For example, here's a start for your test plan.

  1. Start the program
  2. Enter P. It should show all tables empty
  3. Enter R, then 4. Then do P again. It should show a table reserved for four people
  4. Enter R, then 5. It should reject the 5. Enter 3. Then enter P. You should see one table for four people, and another for 3.
  5. Continue reserving tables until all tables are full. Then, try entering one more table. You should see an appropriate error message.
  6. etc ...

Your test plan should continue in this fashion until tests for all program features have been included. When you submit your test plan to the TA, he/she will tell you either that it is "complete", or that it is "incomplete". If it is incomplete, you should figure out which feature has not yet been included and add new tests.

If you get the feedback that your test plan is "incomplete", your TA might or might not give you a hint about which feature is not being tested. Note that he/she can't just "tell you" what's missing... your TA would be writing the test plan for you if your TA did that. So, as frustrating as it may be, you'll just have to figure it out. But if you ask nicely for a hint, one might be provided if you are really stuck.

You must work independently on the actual assignment, but you are permitted to collaborate on the test plan part only. You may work in groups of up to four students: indicate in your submission who you worked with. My advice is that you each write your own test plan independentl first, then discuss your plans as a group and merge them into one. Another way is to write the plan as a group, in "brainstorming mode", with one group member acting as secretary. In any case, you must ultimately each submit a copy of your test plan to WebCT along with your submission for this assignment.

Use emacs to create a text file called lab07_test.txt and put your test plan in that file (in plain english). Your test plan should indicate exactly what items you think need to be tested to ensure that all the functionality of your program has been demonstrated—not just your modificaitons, but the basic functionality given in the sample code as well.

Before proceeding to the final script of your work, get your TA or instructor to approve your test plan. At your TAs discretion, one of two methods may be used (follow your TAs instructions as to which one is acceptable:)

Only one email or print out per group please; use "cc" to include the names of the other folks in your group on the email or printout.

To be sure of being able to complete the lab on time, you should get your test plan approved during the lab session where this assignment is made. If you don't complete the test plan during the lab session, you need to get it done within 48 hours of when the lab is first given out. Your TA is not responsible for any delays that may result from your submitting a test plan for approval later in the week. You should expect anywhere from 24 hours up to 72 hours turnaround time from submission of a test plan to a "yes/no" decision.

Finishing up and Submitting

  1. Make a script that called lab07.txt that follows your test plan. Upload lab07.txt to WebCT and print a copy for your TA.
  2. Submit lab07.txt and lab07.cpp to WebCT.

Grading: 100 points total