Exercise 1
In Assignment 2 you were asked to provide a linked implementation of the following queue interface
public interface Queue {
public int size(); // current queue size
public boolean isEmpty(); // true if queue is empty
public void enqueue(Object element); // add element at end of queue
public Object dequeue(); // return and remove first element.
public Object first(); // return (without removing) first element
public Object last(); // return (without removing) last element
public String toString(); // return a string representation of the queue content
public Iterator iterator(); // element iterator
}
Tasks:
- Provide a similar generic queue interface named Queue<T>.
- Provide a linked generic queue named LinkedQueue<T> that implements the interface Queue<T>
using the head-and-tail approach.
- Write a JUnit test program QueueTest for your generic queue implementation. Make sure that you are using at least two parameter types (e.g. Integer and String) in your tests.
You are of course allowed to reuse your own non-generic queue implementation/test from Assignment 2.
However, make sure to take into account all comments given to you by your teaching assistant when he/she
corrected it.