/**
 * A Queue (of Object objects)
 *
 * This implementation uses contiguous memory
 *
 * @version 1.0
 * @author  Prof. David Bernstein, James Madison University
 */
    public class Queue
   {
      private int           back;
		private int           front;
      private Object[]      contents;
   
      public static final int CAPACITY = 100;
   
    /**
     * Construct a new (empty) Queue
     */
       public Queue()
      {
         back  = -1;
         contents = new Object[CAPACITY];
      }
   
   
   
    /**
     * Pop an Object off of the front of this Queue
     *
     * @return  The Object at the front of this Queue
     */
       public Object dq()
      {
         int     i;
         Object  value;
      
      
         if (back != -1) 
         {
            value = contents[0];
         
         // Shuffle
            for (i=0; i < back; i++)
            {
               contents[i] = contents[i+1];
            }
         
            back  = back - 1;
         
         } 
         else
         {
            value = null;
         }
      
         return value;
      }
   
   
    /**
     * Push an Object onto the back of this Queue
     *
     * @param last   The Object to push
     */
       public void push(Object last)
      {
         if (back < CAPACITY-1)
         {
            back = back + 1;
            contents[back] = last;
         }
      }
   }
