IUP Computer Science
CO 310 Spring 1986
Project #2
In this project you are to write a program to simulate the
operations of a catalog order desk. Three people work at the
desk: two order clerks, each of whom receives catalog orders and
processes refunds at separate windows, and a file clerk, who
files orders received by both order clerks. A typical scene at
the order desk would go something like this: A customer gets in
line at one of the two windows; when the customer reaches the
window, he/she either orders something or returns an article for
a refund (with a previously acquired order form; the order clerk
receives orders and puts them on a pile between the two windows;
the order clerk handles refunds with no further processing; the
file clerk takes order forms from the common pile and files them
in the appropriate distribution folders.
There are six events, which occur at the catalog desk, that
your program must handle. These events may occur in almost any
order; the events are
Customer arrival
An arriving customer gets into line at the
window with the shorter line (in case of a
tie, window #1 is chosen). Data for an
arrival consists of four values with one
space separating each two values; the values
are A (for arrival), O or R (for order or
return), 7-digit order number, 9-digit SSN.
Window closing
Customers in line at the closed window move
as a body to the end of the other window's
line (while maintaining their relative order).
Data for a closing consists of two values
with a space between; the values are C (for
closing) and 1 or 2 to indicate which window
is closing.
Window opening
The customers in the second half of the line
at the other window move as a body (while
maintaining their order) to the newly opened
window. If there are an odd number of people
in line, "the small half" moves to the newly
opened window. Data for an opening consists
of two values separated by a space; values
are O (for opening) and 1 or 2 to indicate
which window is opening.
Next customer
The order clerk processes a refund or puts
the order on the "filing" pile. The data
values are N (for next) and 1 or 2 to
indicate which window (a space separates the
the two values).
File an order
The filing clerk takes an order off the top
of the order pile and processes it. The data
consists of an F (for file).
Report
Occasionally, the supervisor checks on the
catalog desk. At that moment the supervisor
wants a report on the number of customers
who have been handled at each window, the
number currently in line at each window and a
list of the all the orders in the order pile,
in top-down order. The data consists of an
R (for report).
As the day starts, both order windows are open and as the
day procedes, there will always be at least one window open. If
the data attempts to do something impossible (close a closed
window, open an open window, get the next customer when none are
in line, or try to file an order when the pile is empty), your
program should ignore it. Do not count an attempt to get the
next customer as a customer handled unless there is actually a
customer in line. Do not try to perform any unspecified actions,
such as redistributing customers when one line becomes empty but
still open.
You are expected to devise your own test data for your
simulation program. Shortly before the program is due, the
official data will be made available in the file 310DESK.COMPSCI.
Below is a set of sample data to be sure you understand the data
form. On the right is a sample form for the report event. The
report is for the event at the end of the sample data.
Data Report
A O 3245120 284234451
A O 3241255 171230098 Handled Waiting
A R 3240534 201348701 Window 1 2 1 2
N 1 Number 4 1 2 0
A O 3239044 211096542
A O 3243067 191772401 Order Pile
C 2 Order# SSN
N 1 3239044 211096542
A R 3241533 308671212 3245120 284234451
A R 3240078 223459072
N 1
F
N 1
O 2
N 2
R