EmptyCollectionException.java /* * Represents the situation in which a collection is empty. */ public class EmptyCollectionException extends RuntimeException { /* General class level objects */ /* * Sets up this exception with an appropriate message. * @param collection the name of the collection */ public EmptyCollectionException(String collection) { super("The " + collection + " is empty."); } } PriorityNode.java /* * Represents a node in a linked list. */ public class PriorityNode<T> { /* General class level objects */ private PriorityNode<T> _next; private T _element; private int _priority; private final int _MAX_PRIORITY = 100; /* * Creates an empty node with a given priority. */ public PriorityNode(T elem, int priority) { // TODO To be completed as a Programming Project } /* * Creates a node storing the specified element with a default priority. * * @param elem element to be stored */ public PriorityNode(T elem) { // TODO To be completed as a Programming Project } /* * Returns the node that follows this one. * * @return reference to next node */ public PriorityNode<T> getNext() { // TODO To be completed as a Programming Project } /* * Sets the node that follows this one. * * @param node node to follow this one */ public void setNext(PriorityNode<T> node) { // TODO To be completed as a Programming Project } /* * Returns the element stored in this node. * * @return element stored at the node */ public T getElement() { // TODO To be completed as a Programming Project } /* * Returns the priority of this node. * * @return element priority the node */ public int getPriority() { // TODO To be completed as a Programming Project } /* * Sets the element stored in this node. * * @param elem element to be stored at this node */ public void setElement(T elem) { // TODO To be completed as a Programming Project } /* * optional toString() override. */ //public String toString() //{ // // TODO To be completed as a Programming Project //} } PriorityQueue.java /* * LinkedQueue represents a linked implementation of a queue. */ public class PriorityQueue<T> implements PriorityQueueADT<T> { /* General class level objects */ private int _count; private PriorityNode<T> _head, _tail; /* * Constructor - Creates an empty queue. */ public PriorityQueue() { _count = 0; _head = _tail = null; } /* * Adds one element to the rear of this queue. * Higher priorities are inserted closer to the front of the queue * Items with the same priority are processed in normal queue order * * @param element the element to be added to the rear of the queue * @param priority relative priority of the queue item */ public void enqueue(T element, int priority) { // TODO To be completed as a Programming Project // add in-order insertion of the PriorityNode based on getPriority() value // the higher the priority is the closer to head it gets // equivalent priority is normal .