To simulate a stream of arriving customers, we use an instance of the class CustomerGenerator to create them. When a customer is created, it is assigned an arrival time and a service duration. In each case, these values are generated pseudo-randomly in accord with a uniform distribution over a fixed range (going from a specified minimum to a specified maximum). (These minima and maxima are given by the values of the parameters that are passed to the CustomerGenerator constructor.)
For example, in our simulation we could make it so that each "inter-arrival time" (the time between when one customer arrives and then the next) is in the range [0..10] units of time, with each (integer) value in that range being equally likely.
Such simulations can be useful in making decisions about how many clerks ought to be available for customers during certain periods of the day, based upon the frequency with which customers tend to arrive and how long it typically takes to provide service to them. Obviously, the greater the number of clerks, the less time customers will spend waiting in the queue, which will tend to make customers happy. On the other hand, the greater the number of clerks, the greater the amount of their wages, which will tend to displease the business owner. So there is a tradeoff!
The Simulation class (and specifically its simulate() method) is where the simulation actually gets carried out. Four of the methods in that class are left to the student to complete. Extensive comments within the class are there to aid the student in figuring things out! In particular, each of the stubbed methods is responsible for updating the values of one or more instance variables. It is imperative that those updates preserve the truth of all the class invariants1
This assignment involves the following Java classes, one of which needs to be completed by the student:
Four of the methods of this class are to be completed by the student.
Numerous "print" statements are found in the simulate() method. These are strictly for the purposes of debugging during program development and should be commented out in the version that the student finally submits.
This program expects to receive either one or seven command line arguments (or what jGrasp calls "run arguments"). If only one argument is provided, it is interpreted to be the name of a file containing the seven input values. If seven arguments are provided, they are taken to be the seven inputs.
Here is the output produced by one run of this program, in which the "print" statements in the simulate() method of the Simulation class were left intact.
The Simulation class includes two instance variables of the data type arising from the Java interface List, both of which represent lists of Customer objects. As you would expect, a list is simply a sequence of elements. Java's concept of a list is what could be called an indexed list, meaning a sequence whose elements can be referred to by their ordinal positions (e.g., 0th, 1st, 2nd, etc.). Also, you can remove an element at a specified position and insert a new element at a specified position.
The following examples of method calls (in which it is assumed that list is bound to an object of a class (such as LinkedList) that implements the List interface) gives you all the information you need about Java lists for the purposes of this assignment.