import java.util.*; // for JCFs and Random public class Bank // our Bank will have some number of tellers and process Customers based on a duration passed in to the constructor { private Queue queue; // we will have a LinkedList or PriorityQueue (could also use another type such as Stack) private int numCustomers, numTellers, duration, currentTime, totalWait; // numCustomers = total number of Customers at end of simulation, currentTime = loop index, totalWait = sum of all Customer wait times private Teller[] tellers; // our tellers are stored in an array public Bank(String q_type, int numT, int d) // q_type is used if we want a priority queue { if(q_type.equals("priority")) queue=new PriorityQueue<>(); // establish actual line type else queue=new LinkedList<>(); // note: if you add another type like ArrayList or Stack, you will have to alter the enqueue command below as it ishard-coded as offer numTellers=numT; // initialize other variables appropriately duration=d; currentTime=0; numCustomers=0; tellers=new Teller[numTellers]; for(int i=0;i0) // run simulation until we reach time limit AND queue becomes empty { if(currentTime0) { c=queue.remove(); // dequeue totalWait+=currentTime-c.getInTime(); // add the time this Customer waited in line to totalWait tellers[i].newCustomer(c); // add this Customer to tellers[i] } } } currentTime++; // end of this minute, start next minute } } // accessors public int getTotalWaitTime() // total amount of wait time of all Customers { return totalWait; } public int getTotalCustomers() // how many Customers were served during the simulation { return numCustomers; } }