/** ****************************************************************************** * HOMEWORK 1, 15-211 ****************************************************************************** * * This is an implementation of a simple queue structure, using * the built-in LinkedList class. For Homework Assignment 1, you * are required to rewrite this class. . * * * @author V.Adamchik * @date 12/29/04 * @see Caterpillar * @see GameApplet *****************************************************************************/ /***************************************************************************** The Queue class must be replaced by the ArrayQueue class. *****************************************************************************/ import java.util.*; public class Queue extends LinkedList implements QueueInterface { /** * Create a new empty queue. */ public Queue () { super(); } /** * Put a value into the end of the queue. * * @param value element to be inserted into the end of the queue */ public void enqueue (AnyType value) { add(value); } /** * Access the first element in the queue. * * @return element at front of the list * @exception java.util.NoSuchElementException no matching value */ public AnyType getFront() throws NoSuchElementException { if (isEmpty()) throw new NoSuchElementException(); else return getFirst(); } /** * Remove first value in the queue. * * @exception java.util.NoSuchElementException no matching value */ public AnyType dequeue() throws NoSuchElementException { if (isEmpty()) throw new NoSuchElementException(); else return removeFirst(); } /** * Makes the queue physically empty. * */ public void clear() { super.clear(); } }