Laboratory Exercises For Computer Science 153

Multiple Clerks in a Store: An Example of Object-Oriented Design

Multiple Clerks in a Store: An Example of Object-Oriented Design

This lab considers an object-oriented solution to the following:

Problem:

Consider a commercial environment where multiple clerks are available to serve customers. There are at least two models for such service:
  1. 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.

  2. 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.

Movement of Customers

These two models are illustrated schematically in the following diagram.

One- and Multiple-Queues in a Store

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.

Identification of Objects

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.

Timing Issues

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.

Program

A full Scheme implementation of this solution may be found at /home/walker/153/labs/clerks-oo.ss .


This document is available on the World Wide Web as

http://www.math.grin.edu/~walker/courses/153.sp00/lab-oop-multi-clerks.html

created April 8, 2000 by Henry Walker
last revised April 9, 2000