Introduction
java,javaLinkedQueueLinkedStack2,enqueue,dequeue
isEmpty, size, toString(),main
Requirement
CIS 22C
Programming Homework Assignment #2 Page 1 of 2
Programming Homework Assignment #2
Due Date: Sunday May 1, 11:55 PM
• Upload the source files (.java files) with output (copied and
pasted to the end of the main file) (see Catalyst under Week 4
for where to submit)
Problem:
Write a Java program which completes and tests the LinkedQueue class
as declared in the LinkedQueue.java file (in the Queue Code File
folder on Catalyst under Week 2). CHANGE the LinkedQueue file so
that it reads: public class LinkedQueue>
implements QueueInterface, DeepCloneable>
The methods that need to be completed in LinkedQueue.java are:
• default constructor (does nothing)
• deepClone method that returns another LinkedQueue (MUST
make a DEEP COPY) (note: expect T to do a deep clone, too)
• enqueue
• dequeue
• isEmpty
• size
• toString() (public method that returns a String that has all
the data in the Queue separated by a space, BUT NOT CHANGING
ANYTHING in the Queue) THIS ISN’T IN THE LinkedQueue class yet,
so you MUST ADD it!!!!
A “deep copy” or deep clone copies the data elements (T) of the
queue, NOT have the cloned queue refer to the same data elements,
but to clones (copies) of the data elements
HINTS: The Java code for these methods will be VERY SIMILAR to the
LinkedStack class, with a few changes, as mentioned in class, AND
don’t forget:
• enqueue adds to the back of the queue, BUT you must check if it
was empty (if it was, also assign the frontNode, but it not,
link the new node to the old back node)
• dequeue adds removes from the front of the queue, but it
becomes empty after removing it, you need to update the
backNode (you should figure out to what!)
• in the toString() method (which overrides the Object
toString()), DON’T call dequeue nor enqueue and DON’T change
anything in the Queue, but traverse similar to the LList.java
code
Run a bank queue simulation, simplified from other simulations so it
has no priority queue and only 1 teller, AND you are to use a
subclass of the Simulation abstract class given in the
HW2_JavaCodeFile. Other simplifications include not