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
Get step-by-step solutions from verified subject matter experts
