// Program to demonstrate the usage of queues by modeling // a line at a deli counter import java.util.*; public class DeliLine { public static void main(String[] args) { Queue customers = new LinkedList(); getInLine("Caitlin", customers); getInLine("Aaron", customers); getInLine("Zaha", customers); getInLine("James", customers); getInLine("Michael", customers); System.out.println(customers); System.out.println(); serveNext(customers); serveNext(customers); System.out.println(customers); // customers.add(0, "Brett"); // no cuts, no buts, no coconuts customers.add("Brett"); System.out.println(customers); } // add a new person to the line // pre: customers != null public static void getInLine(String person, Queue customers) { customers.add(person); System.out.println(person + " now in line"); } // serve the next person in line // pre: customers != null public static void serveNext(Queue customers) { String next = customers.remove(); System.out.println("Now serving: " + next); if (customers.isEmpty()) { System.out.println(" No one left."); } else { // ??? } } }