| Due Date: Wednesday, November 3 |
Point Value: 100 points
|
In this homework assignment, you will create an OrderedQueue class and an UnorderedQueue class both of which implement a PriorityQueue interface. The classes will be used by a program that maintains a list of prioritized printer jobs. Each job has a number and a positive integer priority with a higher number signifying a higher priority. For example, a priority of 100 is considered higher than a priority of 25. The same job number may NOT appear in the list more than once. The priority must be > 0.
The OrderedQueue class will maintain a linked list in sorted order by priority, with the highest priority job occuring first in the list and the lowest priority job occuring last. For example:
[25 #45897]->[10 #89870]->[5 #94510]->[5 #90888]->NULLwhere the first number is the priority and the second number is the job number.
The UnorderedQueue class will simply add new jobs to the end of the list. For example:
[5 #94510]->[25 #45897]->[10 #89870]->[5 #90888]->NULLIn both lists, jobs with the same priority should appear in the order in which they were added to the list. So if a job with priority 25 for job #89933 was added to the Ordered list shown above it would become:
[25 #45897]->[25 #89933]->[10 #89870]->[5 #94510]->[5 #90888]->NULLThe same message added to the Unordered list would result in the following list:
[5 #94510]->[25 #45897]->[10 #89870]->[5 #90888]->[25 #89933]->NULLThe job, [25 #45897], would be considered the maximum priority job in both lists.
The Node class
and the PriorityQueue interface along with
the TestQueue program
are provided for you in the directory,
/afs/eos.ncsu.edu/courses/csc/csc216/common/www/Homework/5_HW.
The Node class contains as data members an integer priority, priority, a job number represented by the String jobNumber, and a link to the next Node, link. It also contains a toString() method.
Please take the time to examine the TestQueue program listed above to see how it makes use of an interface to use two different data structures to provide the same functionality.
protected Node head;Some methods, as specified in the interface file, must be implemented recursively using helper methods with NO loops or static variables!
protected Node head; protected Node tail;Some methods, as specified in the interface file, must be implemented recursively using helper methods with NO loops or static variables!
csc% java TestQueue OOR
csc% java TestQueue UThe expected output from the test programs is provided in the files, OrderedQueueOutput and UnorderedQueueOutput
Your code must follow the CSC 116/216 Style Guidelines. Every method and class must be documented using javadoc comments. The documentation for each class must contain the "@author" tag as well as the basic description of the class. The documentation of each method must contain a basic description, the "@param" tag for every parameter, the "@return" tag for any non-void returns, and the "@throws" tag if it throws an exception. For example,
/**
* Inserts the integers in the other IntegerList in this Integer List beginning at
* the given index
* @param other other IntegerList
* @param n index in IntegerList where first integer in the other IntegerList should
* be inserted
* @throws java.lang.ArrayIndexOutOfBoundsException
*/
public void insert(IntegerList other, int n)
throws ArrayIndexOutOfBoundsException {