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:

  • input file - customer input file
  • # cashiers
  • time per book - the time it takes a cashier to "ring up" each of book the customer has
  • output file - simulation report file

The Customer file is one line per customer. Fields are comma-separated and each customer line includes:

  • customer name
  • number of books
  • wait start time - time the customer gets in line to checkout

Lines in the Customer file starting with '#' are comments and should be ignored.

Simulation Output

The output of each simulation is:

  • simulation parameters - the input parameters for this run
  • simulation results - total simulation time and average wait for customers
  • simulation details - the details of the simulation for each customer:
    • customer name
    • wait start - time the customer started waiting
    • checkout start - time the customer started checking out
    • checkout done - time the customer's 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. 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 a name 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
   // Read the CustomerList files
   // Simulate
   // Report
}

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.

May 28, 2003

Ugh. Changed the assignment to read Customer files, rather than generate them. STL implementation details made the original assignment harder than I liked. The original assignment would have been difficult to validate and test as well. I have simplified your record-keeping as well.

For the record here's the original:

Old Program #5

Please note the change to use pointers rather than objects in both the CustomerList and CashierList definitions. This will also make your life easier.

Anyway, there are two Customer input files and simulation output files in the prog05 folder of the Common Area:

  • Customer file: cust1.txt, Output file: cust1_report.txt
  • Customer file: cust2.txt, Output file: cust2_report.txt

More input and output files coming soon...

BTW, you shouldn't need my RNG module now as you're not generating Customer files.

May 30, 2003

All test cases are now available in the Common Area. Please read the README.txt file in the prog05 folder for more information.