Homework 6: Bob's Wacky Fun World

Short Description:

Write a program that simulates customers waiting in line at a novelty store.

This assignment is worth 100 points.

Goals

When you finish this homework, you should:

Formal Description

Bob's Wacky Fun World is a novelty shop. To make the experience more fun, Bob has implemented a number of "amusing" features. For example, the "exploding" toilet paper is a real hit.

Bob is considering adding a rotating line. The front of the checkout area will be replaced with a giant rotating disk (much like a merry-go-round), which turns at a rate of 1 turn per hour. At the beginning of the hour, the entrance is just past the 3 o'clock position, and the exit is just past the 9 o'clock position. As time passes, line rotates in a clockwise direction, until just before 1/2 past the hour, the exit is almost to the 3 o'clock position and the entrance is just about to the 9 o'clock position. After 1/2 past the hour, the entrance becomes the exit and the exit becomes the entrance. In other words, the line is reversed. (See the figures below).

Since Bob has had some problems with some of his ideas in the past, he would like you to help him out by simulating what would happen with this configuration.

You should build the following classes:

You should have the following constants in your program:

Output

Each time an event occurs, you should output what happens:
Time O
   The store opens.
 ...

Time 88
   Customer 431 entered the line with 2 items
   The cashier finished processing customer 429
   Customer 429 departs with 20 ticks in line and  1 line rotations,  

Time 89
   Customer 432 entered the line with 3 items
   Customer 430 reached the cashier.
   The cashier will take 6 ticks to process customer 430

Time 90
   The Wheel Spins 
...
Time 600: 
    The store closes. 
...
Time 643
   The cashier finished processing customer 782 
   Customer 782 departs with 13 ticks in line and 0 line rotations 

Discussion

When the wheel spins, you should call a routine which will reverse the order of the queue. This is best done by using the stack. You should keep track of the number of times a customer is

The main loop of your program should look something like this:

OpenStore()
for time=0 to 600 do
   if (time % 30 == 0) 
      ReverseQueue(Q)
   while NewCustomers()
      Q.Enqueue(MakeNewCustomer(time))
   if cashier.IsFree() && !Q.IsEmpty() {
       cashier.AddCustomer(Q.Dequeue())
   }
   cashier.DoTick()
while !Q.IsEmpty()
   time ++
   if cashier.IsFree() && !Q.IsEmpty() {
       cashier.AddCustomer(Q.Dequeue())
   }
   cashier.DoTick()
CloseStore(time)

Submission

This homework is due by class time December 12.