package lab.util; import java.util.ArrayList; import java.util.List; /** * A class for simulating a checkout line. A checkout line is a queue of customers. * */ public class CheckoutLine { private Queue queue; /** * Create a checkout line having an empty queue of customers. */ public CheckoutLine() { } /** * Returns true if there are customers in the checkout line , and false * otherwise. * * @return true if there are customers in the checkout line, and false * otherwise */ public boolean hasCustomers() { } /** * Returns the number of customers in the checkout line. * * @return the number of customers in the checkout line */ public int getNumberOfCustomers() { } /** * Returns a reference to the customer currently at the front of the line * without removing the customer from the line. * Returns null if there are no customers in the line. * * @return a reference to the customer currently at the front of the line, or * null if there are no customers in the line */ public Customer getCurrentCustomer() { } /** * Add a customer to the back of the line. * * @param c * the customer to add to the back of the line * @pre. c != null */ public void addCustomer(Customer c) { } /** * Returns a list of this checkout line's queue of customers. * Modifying the returned list does not modify the queue of customers. * The state of this checkout line's queue of customers after * the method finishes is the same as when the method was invoked. * * @return a list containing this checkout line's queue of customers */ public List getCustomersAsList() { } /** * Process as many customers as possible starting from the front of the queue * given the current simulation time currentTime. * *

* The default behaviour is to dequeue the first customer from the front * of the line ignoring the time. Subclasses should override this method * to process customers in the line given the current time. * * @param currentTime * the current time in seconds of the simulation * @return the queue of customers that have been dequeued from this line * during this update; the queue is empty if there are no customers * in this line */ public Queue update(double currentTime) { Queue processed = new Queue(); if (this.hasCustomers()) { processed.enqueue(this.queue.dequeue()); } return processed; } /** * Provides access to the queue of customers for subclasses. * * @return the queue of customers */ protected Queue getQueue() { return this.queue; } }