Question: Add a test program for the below public class QueueAsMyLinkedList { private MyLinkedList theQueue; // list header public QueueAsMyLinkedList() { theQueue = new MyLinkedList(); }

Add a test program for the below

public class QueueAsMyLinkedList { private MyLinkedList theQueue; // list header public QueueAsMyLinkedList() { theQueue = new MyLinkedList(); } public void enqueue(E newElement) //insert at tail { theQueue.append(newElement); } public E dequeue() //remove from head { E temp = null; boolean isDone = false; temp = theQueue.getFirst(); if (temp != null) { isDone=theQueue.delete(temp); } if (isDone) return temp; else return null; } public String toString() { return theQueue.toString(); } public boolean swapStart() { if (theQueue.length() < 2) { return false; } E temp = theQueue.getFirst(); theQueue.delete(temp); theQueue.insert(temp, 1); return true; } }//end class

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!