Implement a queue as a circular array as follows: Use two index variables head and tail that contain the index of the next element to be removed and the next element to be added. After an element is removed or added, the index is incremented (see Figure 15.15 on page 661).

.

Complete the following file:

CircularArrayQueue.java

Use the following file:

CircularArrayQueueTester.java

/**
   A program to test the CircularArrayQueue class.
*/
public class CircularArrayQueueTester
{
   public static void main(String[] args)
   {
      CircularArrayQueue q = new CircularArrayQueue(5);
      q.add(new Integer(1));
      q.add(new Integer(2));
      q.add(new Integer(3));

      System.out.println(q.remove());
      System.out.println("Expected: 1");
      System.out.println(q.remove());
      System.out.println("Expected: 2");

      q.add(new Integer(4));
      q.add(new Integer(5));
      q.add(new Integer(6));

      System.out.println(q.remove());
      System.out.println("Expected: 3");
      System.out.println(q.remove());
      System.out.println("Expected: 4");
      System.out.println(q.remove());
      System.out.println("Expected: 5");
      System.out.println(q.remove());
      System.out.println("Expected: 6");
      System.out.println(q.size());   
      System.out.println("Expected: 0");
   }
}