Assignment 6 - Linked Lists
Due Before class on Nov 21th
The objective of this assignment is to get more
familiarity with the ADT (Abstract Data Type) concept by implementing
the queue ADT using a linked list data structure as shown in
class. Last week I included a program in the assignment to test your
stack class. This week you will need to develop your own testing program to
try to thoroughly test your queue class. This assignment is also an exercise in "test first"
programming. The idea is to write code which will test your queue
first. Verify that the tests all fail. Then write the code necessary
to make each test pass. If you've thought of all of the important
scenarios to test, then you can be fairly confident you've got
reliable code.
Here are the steps in the assignment:
- Write a test program called QueueTest to test your 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
- Create a ListQueue class with the methods listed in the interface
below, but leave the methods empty so they don't yet do anything.
- 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.
- Look at the first test in your test program and
write just the code necessary to make that one pass. Since it is a
requirement that you use your own linked list implementation of a
queue, you will probably need to create a new class at this point to
use for each node in your list.
- Repeat the previous step with
each remaining test until all tests pass.
- Make sure you've
remembered all of the test cases that need to be tested.
- email your code to me tolnasb@evergreen.edu by the
due date whether
it works or not.
Your ListQueue 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