For example, you note that during peak hours there is a ninety percent chance that a customer will arrive every minute. We create a simulation by first defining objects to represent both customers and tellers. For customers, the information we wish to know is the average amount of time they spend waiting in line. The latter is a value randomly selected between 2 and 8. Customers can also tell us when they are done with their transactions.
Tellers are either busy servicing customers, or they are free.
Tellers define a member function to answer whether they are free or not, as well as a member function that is invoked when they start servicing a customer. Each minute a new customer is, with probability 0.9, entered into the queue of waiting customers. Each teller is polled, and if any are free they take the next customer from the queue. Counts are maintained of the number of customers serviced and the total time they spent in queue. From these two values we can determine, following the simulation, the average time a customer spent waiting in the line.