|CSC 153: Computer Science Fundamentals
|Laboratory Exercise Reading
This reading considers an object-oriented solution to the following:
Grocery Store Model: There is a queue for each clerk. When the customer is ready for service, the customer selects the shortest queue and stays in that queue until being served.
Airport Model: There is only one queue, which all customers enter. When a clerk becomes available, the customer at the head of the queue goes to that clerk for service.
Suppose also that we know the average number of customers that can be expected in a given time interval (e.g., customers per hour) and the average time required for a clerk to serve a customers (e.g., minutes per customer).
Run a simulation to compare the effectiveness of the two models -- specifically determining the relative waiting times of customers in each model.
These two models are illustrated schematically in the following diagram.
While the details of customer movement differ in the two models, the two are similar in that the customer selects which queue, and the clerk looks toward the appropriate queue for the clerk's next customer.
In object-oriented design, the identification of objects often begins by finding the relevant nouns in the statement of the problem. The identification of methods often begins by locating the relevant verbs.
In order to track timing through the simulation, there is a need for a common clock. Also, customers might be expected to keep track of their own time waiting in queues or at a clerk, while clerks might be expected to determine when then are finished with a customer.
Statistics on waiting times and number of customers must be kept somewhere, and this is a candidate for another class.
A full Scheme implementation of this solution may be found at /home/walker/oop/clerks/clerks-oo.ss .
This document is available on the World Wide Web as
created April 8, 2000
last revised February 1, 2005
|For more information, please contact Henry M. Walker at email@example.com.