For this assignment, I want you to create and submit a
Queue.java file in which you
implement a queue class. This queue should ONLY have the following operations as defined
in our lectures.
1. Enqueue: insert an item at the end of the queue
2. Dequeue: delete an item from the beginning of the queue (and return it)
3. Peek: return (but do not delete) the item at the beginning of the queue
4. Size: return the size of the queue
5. IsEmpty: return whether the queue is empty
6. IsFull: return whether the queue is full
7. Equals: compare two queues
8. Add: concatenate two queues
In addition, it should have a constructor, a copy constructor, and output capability i.e.
9. Queue()
10. Queue(Queue s)
11. String toString()
You are to build this queue ON TOP of your
List.java from Assignment #5. In fact, the
only member variable your queue class will require is a generic list. To do this, make
sure that you have a copy of
List.java in the same folder as the
Queue.java file you’re
creating.
• For this assignment, you will be provided with two files:
{
QueueTest.java contains the main function. You may NOT modify this file!
{ QueueTest.out contains the output from my implementation of the queue. You
would be wise to ensure your output is EXACTLY the same (That includes
spacing and formatting).
• Recall that the only file you will submit is (
Queue.java). If you have implemented it
correctly, It should work with my version of
List.java• Label the file by typing your name in a commented section at the top of the
Queue.javafile.
• Compiling
QueueTest.java should automatically use your
List.java and
Queue.javafiles (assuming they are in the same directory). After successful compilation, executing
the QueueTest.class file SHOULD produce output identical to QueueTest.out.
• Feel free to redirect the output to a file of your choosing, and then compare the two files
(i.e. QueueTest.out, and your output file) using the command prompt. For example,
once completed, the three commands below should NOT produce any output.
Linux:
javac
QueueTest.javajava QueueTest myOutput
diff QueueTest.out myOutput
Windows:
javac
QueueTest.javajava QueueTest myOutput
fc QueueTest.out myOutput