import java.util.ArrayList;
public class MyArrayListQueue implements  Queue {
	private ArrayList myQ;;
	public MyArrayListQueue(){
		myQ = new ArrayList();
	}
	public int size(){
		return myQ.size();
	}
	public boolean isEmpty() {
		return (myQ.size() == 0 );
	}
	public Object front() throws QueueEmptyException {
		if ( isEmpty() ){
			throw new QueueEmptyException("there is no front in an empty queue");
		}
		else {
			return myQ.get(0);
		}
	}
	public void enqueue(Object o) {
		myQ.add(o);
	}
	public Object dequeue() throws QueueEmptyException {
		if ( isEmpty() ) {
			throw new QueueEmptyException("nothing to remove from an empty queue");
		}
		else {
			return myQ.remove(0);
		}
	}
} // end class MyArrayListStack

public interface Queue {
	public int size();
	public boolean isEmpty();
	public Object front() throws QueueEmptyException;
	public void enqueue(Object o);
	public Object dequeue() throws QueueEmptyException;
} // end interface Queue

public class QueueEmptyException extends Exception {
	public QueueEmptyException() {
	}
	public QueueEmptyException(String s ) {
		super(s);
	}
} // end class StackEmptyException


class TestMyArrayListQueue {
	public static void main(String [] s) {
		MyArrayListQueue qq = new MyArrayListQueue();
			// add a few Objects to the stack
		for (int i = 1; i < 10; i++) {
			qq.enqueue("object"+i);
			System.out.println("inserted to Q: object"+ i);
		}
		System.out.println("The size of the queue = " + qq.size());
		System.out.println("\n\n");
			// print the elements of the stack while removing them
		while ( ! qq.isEmpty() ) {
			try {
				System.out.println("removing from Q:  " +  qq.dequeue() );
			}
			catch (QueueEmptyException e ) {
				e.printStackTrace();
			}
		}
		System.out.println("The size of the queue = " + qq.size());
		System.out.println("\n\n");
	}
} // end class