Implement the interface I provided for a Queue. A Queue is a container to hold d
ID: 3696636 • Letter: I
Question
Implement the interface I provided for a Queue. A Queue is a container to hold data where items are added at the end (enqueue) and removed from the front (dequeue). It is just line a line at the supermarket: first in- first out or first come-first served I provided the interface code and a test driver class with main( ). You are to write the Queue class, implementing all the methods specified in the interface and test it with the Driver. Also, open the driver and write the additional code I specify in the comments. You must document each method with the javadoc tags and inline comments> You must follow the conventions in naming fields, methods, class names and local variables. The JAva API does have classes that do the work of a queue.
You are NOT to use these classes. Do not use the ArrayList Java API class.
1)
/**
* This class contains main( ). It is
* used to test the methods of the ArrayQueue
* class.
*
* @author
*
*/
public class Driver
{
public static void main(String[ ] args)
{
//create an instance of the queue specifying the data
//type in the queue will be Integer. Set the initial
//capacity of the queue to 5
ArrayQueue myQ = new ArrayQueue(10);
//enqueue some data in the queue
myQ.enqueue(3);
myQ.enqueue(7);
myQ.enqueue(6);
myQ.enqueue(4);
//Print how many items are in the queue
System.out.println("The number of elements that have been enqueued is " + myQ.size( ));
//take a look at what is at the front of the queue
System.out.println("The element at the front of the queue is " + myQ.first( ) );
//Now dequeue the front of the queue and print the element after it is removed
System.out.println("The data item being dequeued is " + myQ.dequeue( ));
//now take a look at how many eelements are left in the queue and what the
//data item at the front of the queue is
System.out.println("The number of elements now in the queue is " + myQ.size( ));
System.out.println("The element at the front of the queue is " + myQ.first( ));
//now print the entire contents of the queue after the data item 3 has
//been dequeue
System.out.println(myQ.toString( ));
myQ.enqueue(8);
System.out.println("This is the contents of the queue after enqueueing an 8 " + myQ.toString( ) );
//to do for you
//copy all of the code above but create a queue that will
//hold Strings instead of Integer. Put some String in the queue
//instead of the ints I enqueued.
}//end of main( )
}//end of Driver class
2)
/**
* QueueADT defines the interface to a queue collection.
*
* @version
*/
public interface QueueADT
{
/**
* Adds one element to the rear of this queue.
* @param element the element to be added to the rear of the queue
*/
public void enqueue(T element);
/**
* Removes and returns the element at the front of this queue.
* @return the element at the front of the queue
*/
public T dequeue();
/**
* Returns without removing the element at the front of this queue.
* @return the first element in the queue
*/
public T first();
/**
* Returns true if this queue contains no elements.
* @return true if this queue is empty
*/
public boolean isEmpty();
/**
* Returns the number of elements in this queue.
* @return the integer representation of the size of the queue
*/
public int size();
/**
* Returns a string representation of this queue.
* @return the string representation of the queue
*/
public String toString();
}