/** * The customore definition for the Bank Simulator. * Customers note the time that they came into the bank and * they know the complexity of their transaction * @author gtowell * Created: Jan 3 2020 */ public class Customer { /** The time the customer's transaction will take */ private int timeForTransaction; /** Timestamp of whent eh customer got into line */ private long arrivalTime; /** Timestanp of when the customer finished */ private long completionTime; /** * Create a customer * @param ttime the length of time their transaction will take. */ public Customer(int ttime) { arrivalTime = System.nanoTime(); timeForTransaction = ttime; } /** * Accessor for the transaction time * @return the time required for the transaction */ public int transactionLength() { return timeForTransaction; } /** * Indicate that the transaction has been completed */ public void completed() { completionTime = System.nanoTime(); } /** * The time the customer was in the bank * @return the time the customer was in the bank */ public double waitTime() { return (completionTime-arrivalTime) / 100000000.0; } }