Purpose

This assignment gives you experience developing a class that implements a queue using a circular array. In this assignment, you will ignore the possibility of needing to expand capacity. The test case code provided does not test your code for its behavior in that situation.

Preliminary

Prior to the assignment, do the following to get started:

Download, save, and unzip the file queue_impl.zip on your removable media (floppy disk, Zip disk, or memory stick) creating a directory.

Study the code for the CircularArrayQueue class so that you understand what it needs to do. This code is not complete.

Lab Activities

You need to design and add code to the methods of the CircularArrayQueue class in places as indicated by the comments:

  1. In the constructor(int initialCapacity), you need to instantiate the array and initialize the attributes: front, rear, and count.
  2. In the enqueue method, you need to add an element to the array in the correct place based on the state of the circular array.
  3. In the dequeue method, you need to return an alias of the reference to the first element in the queue and remove it.
  4. In the first method, you need to return an alias of the reference to the first element in the queue.
  5. Depending on your choice of IDE, compile the program. Test your code with TestQueue.java. This will run four different JUnitTestCases on your implementation of the CircularArrayQueue class. This will verify that your code:
  6. Instantiates a CircularArrayQueue object with the correct initial state.
  7. Processes enqueue method calls and leaves the object in the correct state.
  8. Processes dequeue method calls and leaves the object in the correct state.
  9. Handles wraparound of the contents of the queue in the array correctly.

Lab Report (in memo.txt)

At least 200 words: In your own words describe your strategy for the design of the CircularArrayQueue decision logic. Did you consider any other ways to do it?Why did you choose to do it the way you finally did it?