import java.util.*;
//------------------------------------------------------------------------------
//Using a custom Queue class, including push() and pop()
//------------------------------------------------------------------------------
public class queue2 
{
    public static void main(String[] args) 
    {
        Queue<String> customers = new Queue<String>();

        customers.push("Sam");                              //add at end
        customers.push("John");
        customers.push("Larry");
        customers.push("Steve");
        
        String customer;

        System.out.println("The Queue:");
        System.out.println(customers);                      //print the entire queue
        System.out.println();

        customer = customers.pop();                         //remove from start        
        System.out.println("Next on line: " + customer);    
            
        customer = "Joe";
        customers.push(customer);                           //add to end
        System.out.println("Adding new customer: " + customer);    

        System.out.println(customers);                      //print the entire list
        System.out.println();

        customer = customers.peekFirst();                   //peek but not remove        
        System.out.println("Next on line: " + customer);    

        System.out.println("is the line empty? " + customers.isEmpty());
        System.out.println();
        
        //Using the for loop ----------------------------------------------------

        for (int i=0; i<customers.size(); i++)
        {
            System.out.println(customers.get(i));
        }
        System.out.println();

        //Using the enhanced for loop ------------------------------------------

        for (String nextCustomer : customers)
        {
            System.out.println(nextCustomer);
        }
        System.out.println();

        //Using an iterator with a while loop -----------------------------------

        Iterator i = customers.iterator();                  //create an iterator

        while(i.hasNext())
        {
            System.out.println(i.next());
        }
        System.out.println();
    }
}