/****************************************** * Seg 2501, hiver 2002 Devoir # 4 * * file Caissiere.java * Simulates a number of cashiers and their * temporal behaviour when serving clients. * * @author Anne Bertrand * @author Robin Tropper * @refactoredBy Robin Tropper B.Sc.A. * ******************************************/ import java.util.*; class Cashier { private String name; private Timer scheduleNextClient; private long paperWorkTime; public Cashier(int num) { scheduleNextClient = new Timer(); name="Cash_"+num; //estimons de 2 à 4 minutes pour la //paperasse entre clients paperWorkTime = GenerateurR.generer(30, 10); System.out.println("START "+name); nextClient(); }//fin constructeur class ServeNext extends TimerTask { Cashier caisse = null; public void run() { nextClient(); }//fin du run }//fin de classe interne private void nextClient(){ Client clientToServe = null; List queuesInBank = Bank.showQueues(); long servingTime = -1; while( clientToServe == null ){ //OPTIONNaL : //time for paperwork! try { Thread.sleep( paperWorkTime ); } catch (InterruptedException e1) { e1.printStackTrace(); } //find the next client out of the various queues for(int i=0; i