// CSE 143, Summer 2016 import java.util.*; // Simple setup for customers waiting to be served. Customers // added first should be served first. public class Customers { public static void main(String[] args) { // This is the perfect time to use a queue; we want to see // the first customer added as the first customer served. // No cutting! Queue customers = new LinkedList(); customers.add("Melissa"); customers.add("Chloe"); customers.add("Halden"); customers.add("Cody"); customers.add("Tanvi"); customers.add("Shobhit"); System.out.println("customers = " + customers); System.out.println("Who's next? " + customers.remove()); // This won't work anymore, because we're using a queue. // Prevents Daniel from cutting! // --- // customers.add(0, "Daniel"); // So now, our only choice is to go to the back. customers.add("Daniel"); System.out.println("customers = " + customers); System.out.println("Who's next? " + customers.remove()); } }