CS 112
Homework 7
Due on Wednesday 11/3/2004 by 12:00 a.m.


Part I: Queue class

Develop a Java class, a Java application and a Java applet to implement and test a queue data structure (for integers).
The Queue data structure has the basic queue operations In and Out, Full and Empty, plus a function Print for testing and Draw for visualizing. The queue implementation is circular, and the allocated size is EXACTLY 3 (to allow for easy testing). IN and OUT should print error messages when the queue is full (resp. empty).

The (application) testdriver should be menu-based, with one option for each of the five operations (IN, OUT, EMPTY, FULL and PRINT).

The applet should have buttons for all the above operations. In addition, it should correctly visualize the queue by representing (drawing) only the part of the allocated structure that is currently occupied.

Part II. Halloween: waiting in line for pumpkins!!!

As an application of the Queue data structure, you will develop an applet to simulate a "real-life" situation where waiting in line is needed.

After graduation, Meggie Smith decides to start her own on-line business, Pumpkins.com. She has to decide whether she will need to hire any additional help during the busy October period. She is advised to build a computer model for her business, and - using simulation techniques - to infer whether she is likely to be able to handle the orders on her own, or not.
Your task is to build the computer model for Meggie. More precisely, you will design a Java applet simulating a business day for the pumpkin business, which works roughly like this:

Technical specifications



You must test your applet on several values of the simulation parameters, and, in each case, try to interpret the results: shall you hire some additional help? What would be a reasonable range of pumpkin sizes that your business could handle without additional help, and what would be the income it will generate? Be ready to demonstrate the homework in class, together with its usage and the interpretation of the data.

For extra credit, you may implement additional features. For instance, a realistic assumption for a real store, where customers arrive and wait in line to be served, is that a customer will leave if not served after a certain number of time units. Another realistic assumption is that the line cannot grow too big (the queue should be of a fixed size): a customer will leave if the line is too long (and the store will lose business, hence income, if this happens).

Grading guidelines (for the TA)


Ileana Streinu