Can someone please help me fill in the missing code, thanks
/**
* class ArrayQueue
*
* @author <yourname>
* @version 1.0
*/
public class ArrayQueue implements Queue
{
// instance variables - replace the example below with your own
private Object[] entries;
private int capacity;
private int head;
private int tail;
private int size;
/**
* Constructors for objects of class ArrayQueue
*/
public ArrayQueue()
{
entries = new Object[10];
this.capacity = 10;
makeEmpty();
}
public ArrayQueue(int capacity)
{
entries = new Object[capacity];
this.capacity = capacity;
makeEmpty();
}
/**
* Method makeEmpty
*
**/
private void makeEmpty()
{
// CODE REQUIRED
}
/**
* Method destroy - sets all queue entries to null
*
**/
public void destroy()
{
makeEmpty();
}
/**
* Method size
*
* @return number of entries in queue
**/
public int size()
{
return size;
}
/**
*
Test if the array is logically full.
* @return true if full
*/
public boolean isFull( )
{
// CODE REQUIRED
}
/**
* Test if the array is logically empty.
* @return true if empty
*/
public boolean isEmpty( )
{
// CODE REQUIRED
}
/**
* private method to increment with wraparound.
* @param x index
* @return x+1, or 0, if x is at the end of theArray.
*/
private int increment( int x )
{
// CODE REQUIRED
}
/**
* Add a new entry to the queue.
* @param Object o the item to insert.
*/
public void add( Object o )
{
// CODE REQUIRED
}
/**
* Remove an entry from the queue.
* @return Object - the front queue entry
*/
public Object remove()
{
// CODE REQUIRED
}
/**
* Method iterator
*
* @return Iterator - an ArrayQueueIterator object
**/
public Iterator iterator()
{
return new ArrayQueueIterator();
}
/**
* Nested class ArrayQeueIterator provides an iterator for the ArrayQueue class
*/
protected class ArrayQueueIterator implements Iterator
{
int nextIndex;
// Default constructor
ArrayQueueIterator()
{
nextIndex = head;
}
/**
* method next in nested ArrayQueueIterator class
*
* @return Object - the next entry
**/
public Object next()
{
Object theDataItem = entries[nextIndex];
nextIndex = increment(nextIndex);
return theDataItem;
}
/**
* method hasNext in nested ArrayQueueIterator class
*
* @return true if the end of the queue has not been reached
**/
public boolean hasNext()
{
return nextIndex!=increment(tail);
}
}
}