Since, there exist a single cash register and only one customer can access it at given moment. A binary semaphore can be used to control customers waiting to pay from paying together, but would ensure they pay one by one.
Since, customer with smallest order needs to get change to aquireCounter first Waiting Area is implemented as TreeSet which automatically sorts objects, if object implements Comparable interface. Customers just need to check whether they are first in Tree Set to know whether they are eligible to acuire Counter Location, if available.
World.log("Admitted one customer " +customer.getCustomerName() + ", additional space for " + customerSemaphore.availablePermits() + " customers available. Waiting area consits of " + customersWaitingForBurrito.toString());
World.log(serverName + " made " + burritosToMake + " burritos for " + customerToServe.getCustomerName() + ", customer still requires " + (customerToServe.getOrderBurritoCount() - customerToServe.getAcceptedBurritos()) + " burritos."); ...Show more