create your own generic Queue class using a LinkedList as the underlying data type (a composition…

150 150 admin

CS143 – Lab 2
Linked List Queue
A queue is an ADT that represents an ordered, First-In-First-Out (FIFO) collection.
• An ordered collection maintains the insertion order of the elements.
• New elements can only be added to the back of the queue.
• Existing elements can only be removed from the front of the queue.
A queue can be used in real-world modeling, such as keeping track of service requests so that they are
handled in the order they arrived. It can also be used internally in computer functions, such as storing
printer requests in a print queue.
The basic methods for a queue are as follows:
• enqueue(value) – adds the value to the back of the queue.
• dequeue() – removes the next available value from the front of the queue and reports the value.
• isEmpty() – reports if the queue is empty.
Other convenience methods are usually added:
• front() – returns the value at the front of the queue without removing it.
• size() – returns the number of values currently stored in the queue.
Java’s LinkedList and ArrayDeque concrete classes implement the queue ADT, but they also include
many other methods that do not prevent the access to data that should not be accessible in a pure
queue implementation.
Lab Overview
In Lab 2 your task is to create your own generic Queue class using a LinkedList as the underlying data
type (a composition relationship.) This type of relationship allows you to hide LinkedList methods that
are not applicable to a queue.
In the Project 2 module you are given a NetBeans project that contains the following classes:
• An interface named PureQueue that defines the ADT described above.
• A data-management class called Queue that implements the PureQueue interface. (This class is
currently mostly empty.)
• A JUnit test class that tests the Queue class. (Found under TestPackages/cs143.)


Hi there! Click one of our representatives below and we will get back to you as soon as possible.

Chat with us on WhatsApp