Question: Expand the implementation of the class Queue presented in Figure 3.26 to include methods to reinitialize the queue to empty, test for an empty queue
Expand the implementation of the class Queue presented in Figure 3.26 to include methods to reinitialize the queue to empty, test for an empty queue (underflow condition), test for a full queue (overflow condition), and to perform a Peek operation. Include a progressively developed driver program to demonstrate the functionality of each new method. ( This is a re-post since the images of the referenced code did not appear in the first post)
Figure 3.26:

And the main class:

1 public class Queue 2. private Listing data; private int size; private int numOfNodes; private int front; private int rear public Queue () { size= 100; numofNodes0; front = 0; rear 0; data = new Listing[ 100]; 12 public Queue (int n) { size=n; 15 17 18 19 20 21 public boolean enque (Listing newNode) numOfNodes = 0; front 0; rear 0; data new Listing[n]; if (numof Nodessize) 23 return false overflow error else 25 26 27 28 29 numofNodes numof Nodes1; data [rear] = newMode.deepCopy(); rear (rear + 1) % size return true; I push operation successful 31. public Listing deque() 32. int frontLocation return null; underflow error else 35 36 37 frontLocation front; front (front + 1) % size; numOf Nodes numOf Nodes 1 ; return datalfrontLocation] 40 42. public void showA1l() 43.int front; for (int c 1 cnumOfNodes; c++) System.out.printin(datali).tostringO i=(i + 1) % size; 45 46 47 48. I end of showAll method 49. / end of class Queue
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
