/**
 * A Queue with no fixed capacity.
 *
 */

import java.util.ArrayList;

public class Queue {
	
	/** contents[0 .. size - 1] contains the elements of this Queue. */
	private ArrayList<Object> contents;
	
	/** A queue with no fixed capacity.
	 * 
	 * @param n capacity of this Queue.
	 */
	public Queue() {
		contents = new ArrayList<Object>();
	}
	
	/**
	 * Append o to this Queue.
	 * @param o object to be appended.
	 */
	public void enqueue(Object o) {
		contents.add(o);
	}
	
	/**
	 * Remove and return the front element of this Queue.
	 * @return front element of this Queue.
	 * Requires: size >= 1
	 */
	public Object dequeue() {
		Object head = contents.remove(0);
		return head;
	}
	
	/**
	 * Return the number of elements in this Queue.
	 * @return the number of elements in this Queue.
	 */
	public int size() {
		return contents.size();
	}
	
	/**
	 * Checks if this Queue is empty.
	 * @return true if this Queue is empty.
	 */
	public boolean isEmpty() {
		return (contents.size() == 0);
	}
	
	/**
	 * Checks if this Queue contains the specified element.
	 * @param o the element to be searched for.
	 */
	public boolean contains(Object o) {
		return contents.contains(o);
	}
	
	/**
	 * Returns a string representation of this Queue.
	 * @return a string representation of this Queue.
	 */
	public String toString() {
		return contents.toString();
	}
} // Queue
