Purpose

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

Prep

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

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

Copy your CircularArrayQueue class from the previous homework assignment into this directory.

Study the lecture notes about the expand capacity problem for the CircularArrayQueue class so that you understand what it needs to do.

Assignment Activities

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

In the enqueue method, you need to add a check for the need to expand capacity before updating the queue array and if needed, call the private expandCapacity method.

In the private expandCapacity method, you need to add the code to instantiate a new array twice the size of the existing array and copy all of the contents of the smaller array into the larger array so that the next element can be added.

If you're doing this as a DrJava project, using the menu Project -> Compile Project, compile the program. Test your code by selecting the TestQueue.java file and using the DrJava Tools -> Test Current Document menu. This will run one different JUnit TestCase on your implementation of the CircularArrayQueue class to verify that your code now handles the expandCapacity situation correctly.

Lab Report (in memo.txt)

At least 200 words: In your own words, describe your strategy for the design of the updates to 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?