Assignment 7 - A Queue using Java Collections Framework

Due Before class on Dec 12th

The objective of this assignment is to create yet another Queue class but this time using Java's built-in Collections Framework which makes the job much easier. In particular, you will want to use the LinkedList class provided in Java's library of collections classes.

My CStack (Collection-based stack) example from class is a stack that uses a LinkedList to create (implement) another version of the stack class.

Here are the steps in the assignment:

  1. Write a test program called CQueueTest to test your collection-based queue similar to the one I wrote in class for my stack example (see link to code below). It won't compile until you've created your queue class. If you've already created one for the last assignment it should only require a small change to make it use your new CQueue class
  2. Create a CQueue class with the methods listed in the interface below, but leave the methods empty so they don't yet do anything.
  3. Test your test program by compiling and running it. All of your tests should fail since the queue class has methods that don't do anything yet. If the tests don't all fail, fix the test program until they do.
  4. Look at the first test in your test program and write just the code necessary to make that one pass. Use the CStack example as a guide.
  5. Repeat the previous step with each remaining test until all tests pass.
  6. Make sure you've remembered all of the test cases that need to be tested.
  7. email your code to me tolnasb@evergreen.edu by the due date whether it works or not.

Your CListQueue class should have at least the following interface:

public void add(Object o)
Adds a new object onto the end of the queue.
public Object remove()
Removes an Object from the begining of the queue and returns that object.
public boolean notEmpty()
Returns true if there is at least one object in the queue. Returns false if the queue is empty.

Helpful Links