CMPU 102 - Assignment 6 Due: by 4:59 PM on Friday, October 14th


Recall from class that a queue is a First In, First Out (FIFO) data structure.  Elements are taken out of the queue (dequeued) in the same order they are put into the queue (enqueued).

In this project, you will implement a generic queue class.  It will be generic because it will have a type parameter that represents whatever type of elements will be stored in the queue.

The Queue interface defines the operations (methods) that all queues must support:

public interface Queue<E> {
    public boolean isEmpty();
    public void enqueue(E elements);
    public E dequeue();

As you can see, the Queue interface has a type parameter E representing the element type.

Getting Started

First, you should think carefully about how you will store the elements in the queue, so that the enqueue and dequeue operations can be implemented.  Possibilities include sing a linked list to store the elements, or an array.  In any case, your queue class should not have any arbitrary limitation on the number of elements that can be stored in it.  You should sketch out your strategy for implementing the queue on paper before you write any code.  Drawing pictures showing how the data structure is modified as elements are enqueued and dequeued will be very helpful.

When you're ready to start coding, start by importing the file into Eclipse: from the menu, choose "File->Import->Existing Projects into Workspace", click "Select archive file", select "" from the file selection dialog, and then click the "Finish" button.

Defining your queue class

In Eclipse, right click on the "edu.vassar.cs.cs102.queue" package, and choose "New...->Class".  In the "Name:" field of the dialog, type the name of your queue class, followed by the type parameter declaration "<E>".  Click the "Add..." button, choose the Queue interface in the resulting dialog, and click "OK".  Back in the "New Java Class" dialog, the Queue entry will be selected for editing.  Type "<E>" at the end, after the word "Queue".  Make sure the "Inherited Abstract Methods" checkbox is checked.  The dialog should now look like this:

Click the "Finish" button.

In addition to implementing your queue class (and any other classes needed to make it work), you also need to modify the QueueFactory class, which has methods to create new queue objects with element types String and Integer.


The TestQueue class contains several JUnit tests.  Add additional tests so that your queue class is tested with both String and Integer element types, and so that each method is tested thoroughly.

Submitting Your Work

To submit the project, type the following commands in a terminal window (hitting return after each command):

cd eclipse-workspace
submit102 genericqueue

You may submit as many times as you wish.  The final submission prior to the deadline will be graded.