//<PLAINTEXT>
import java.util.*;

/**
 * LQueue.java
 *
 *
 * Created: Mon Mar 24 22:24:44 2003
 *
 * @author <a href="mailto:shapiro@cse.buffalo.edu">Stuart C. Shapiro</a>
 */

public class LQueue {
    private LinkdList front, rear;

    /**
     * Creates a new <code>LQueue</code> instance.
     *
     */
    public LQueue (){
	front = new LinkdList();
	rear = front;	
    }

    /**
     * Determines if this queue is empty.
     *
     * @return true if this queue is empty; false otherwise.
     */
    public boolean isEmpty() {
	return front.isEmpty();
    }

    /**
     * Returns the first element on this queue.
     *
     * @return the first <code>Object</code> on the queue.
     * @exception NoSuchElementException if this queue is empty.
     */
    public Object front() throws NoSuchElementException {
	return front.getFirst();
    }

    /**
     * Adds an <code>Object</code> to the rear of this queue.
     *
     * @param obj the <code>Object</code> to be added to this queue.
     */
    public void enqueue(Object obj) {
	rear.add(obj);
	rear = rear.getRest();
    }

    /**
     * Removes the <code>Object</code> that is at the front of this
     * queue, and returns it.
     *
     * @return the <code>Object</code> at the front of this queue,
     * having removed it from this queue.
     * @exception NoSuchElementException if this queue is empty.
     */
    public Object dequeue() throws NoSuchElementException{
	Object obj = front.getFirst();
	front = front.getRest();
	return obj;
    }

    /**
     * Returns a <code>String</code> representation of this queue,
     * showing all the elements of it, with the first at the left,
     * surrounded by parentheses.
     *
     * @return a <code>String</code> representation of this queue,
     * showing all the elements of it, with the first at the left,
     * surrounded by parentheses.
     */
    public String toString() {
	return front.toString();
    }

}// LQueue
