CSC 161 Program #5

Nerd Book Emporium
Assigned: Fri May 23, 2003 Due: Fri Jun 6, 2003
Grade: 80 points  

Concepts

The "new" concepts covered in this program are:

  • Lists, stacks & queues

  • Standard Template Library (STL) classes

Description

The renowned owner of the Nerd Book Emporium (NBE) wants to analyze his staffing. He wants you to write a program to simulate the time customers have to wait to checkout with their items, nerd books.

Simulation Input

Each simulation should query the user for the following input values that will guide your simulation:

  • # customers
  • # cashiers
  • time period - simulation time over which customers keep arriving
  • # books per customer - the number of books per customer is randomly generated using a normal ("bell curve") distribution, so there are two numbers here: #books mean, and standard deviation
  • time per book - the time it takes a cashier to "ring up" each of book the customer has
  • angry customer limit - a customer is considered angry or disgruntled if he/she is force to wait longer than this
  • output file - name of the simulation output file

Putting it all together... You are simulating the arrival of # customers being served by #cashiers. Customers arrive randomly from time 0 to the time period specified. Each customer is simulated to "buy" a random number of books determined using the #books per customer mean and standard deviation. Cashiers spend time per book * the customer's # books to checkout each customer's purchases. Customers get mad if they have to wait more than the angry customer limit. The results of the simulation run are sent to output file.

Simulation Output

The output of each simulation is:

  • simulation time - total time for the simulation until all customers were served
  • average wait - the average waiting time for customers during the run
  • angry customers - number of "angry" customers during the run
  • percent angry - percent of the customers that were angry
  • simulation file - the results of the simulation for each customer:
    • customer ID
    • cashier ID - the cashier that served this customer
    • wait start - time the customer started waiting
    • wait done - time the customer's wait ended, and he/she was checked out

Putting it all together for output this time... The run ends at simulation time after the last customer is served. Report stats including the average wait experienced by customers, the number of  angry customers, and the percent angry customers. A simulation file detailing the interaction with each customer is also written.

Implementation

My implementation included the following classes:

  • Cashier - has an ID for the cashier and an STL queue<Customer *> that holds the line of customers for this cashier.
  • CashierList - derived from an STL class vector<Cashier>
  • Customer - has an ID for the customer, the number of books the customer wants to buy, and the time the customer started and finished waiting.
  • CustomerList - derived from the STL class list<Customer>

The structure of my main() function looks like this:

main() { 
   // Get user input values
   // Create the CashierList
   // Create the CustomerList
   // Simulate
}

I have provided code for you to generate random numbers for a uniform distribution (like rand()) and a normal distribution (for the # books per customer). It's called RNG and the files (RNG.h and RNG.cpp) are in the Common Area/prog05 folder.

I will give more implementation hints next week. We'll talk a lot more about what simulate() does and STL specifics.

As always, these are hints and not requirements.

 


Grading

Your program will be graded on three areas: design, quality, and function. Their description and weighting in your grade is given below.

1. Program Design (25%)

It is essential to design your program before pounding it out in front of Visual C++. The design for this program requires:

  • A header each class that you design with member variables and functions defined and commented.
  • A pseudo-code description of main().

You should include all the class interface files in your main() and be able to compile, but not build (or link) because your class member functions are not yet written.

2. Program quality (25%)

I'm working on a more comprehensive style guide, but here's what I will be looking for:

  • File comments - at the top of the file, list the file name (for printing purposes), your name, the date, "CSC 161", and what the file contains
  • Class comments - describe the purpose of the class
  • Function comments - describe the purpose of each function, it's parameters and return value if any
  • Variable comments - describe the purpose of each variable
  • Block comments - describe large or complex blocks of code in your functions
  • Well-chosen names - descriptive names for classes, functions, variables, etc.
  • Proper indentation - consistent indentation, just use the built-in facilities in Visual C++, and you'll be golden.
  • Readability - nice spacing of major sections and functions, clear flow and design

3. Program function (50%)

If your program doesn't compile or link, your grade for this section will automatically be cut in half and then I'll start from there. Please leave a README file in your prog01 folder with notes you want me to read.

Good luck.

Notes

As I mentioned in class, I will award 8 extra credit points for students that get "halfway" through this program by Friday May 30. I'll go over all this in more detail at class Wednesday, but "halfway" will definitely include:

  • Create your main() shell to get your input parameters from the user.

  • Create your CustomerList and print it out for debugging purposes

  • Create your CashierList and print it out for debugging.

If you do this, then you're basically left with the mechanics of the simulation of N customers using M cashiers.

I will give you specific simulation runs that I want to see.