package datahiding;


//[partial1
/**
 * A Queue (of String objects)
 *
 * @version 1.0
 * @author  Prof. David Bernstein, James Madison University
 */
public class Queue
{
    private Node back, front;


    /**
     * Construct a new (empty) Queue
     */
    public Queue()
    {
       front = null;
    }


    /**
     * Pop a String off of the front of this Queue
     *
     * @return  The String on the front of this Queue
     */
    public String pop()
    {
//]partial1
       String  value;


       if (front != null) 
       {
          value = front.value;
          front = front.next;
       } 
       else
       {
          value = null;
       }
       return value;
//[partial2
    }


    /**
     * Push a String onto the back of this Queue
     *
     * @param s   The String to push
     */
    public void push(String s)
    {
       Node temp;

       temp = new Node();
       temp.value = s;
       temp.next = null;

       if (front == null)
       {
          front = temp;
       }
       else
       {
          back.next = temp;
       }

       back = temp;
    }
}
//]partial2
