Due: Monday 6/9/14 @5:30pm
Purpose: This homework gives you experience developing a class that implements a java.util.Queue using a circular array.
You need to design and add code to the methods of the CircularArrayQueue class (which extends QueueADT not java.util.Queue) 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. 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.
6. 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.
7. Write a file memo.txt that discusses the challenges you faced, how to solved them or not, and what you learned from the assignment.
Download the code needed: hw2
//to compile with junit javac -cp .:junit.jar *.java //to run the test cases java -cp .:junit.jar junit.textui.TestRunner QueueTest java -cp .:junit.jar junit.textui.TestRunner QueueExpandTest
On the UNIX system in a folder called ‘hw2’ put the following files (or more):
These files can also be in an ‘src’ folder so that you can use the folder as an eclipse project.
Grading (total 10 points):
2 points: Implement enqueue (testEnqueuingNoWrap)
2 points: Implement dequeue (testDequeuingNoWrap)
1 points: Implement enqueue with wrapping (testWrapAround)
3 points: Implement expandCapacity (testExpandCapacity)
2 points: memo.txt and how easy the assignment is to grade
Homework derived from work by Professor Bob Wilson (UMass Boston)