Assume that the SampleQueue class, with the given code below, is used in the TestSampleQueue that is also shown below. Show the output of the TestSampleQueue. Do the exercise without using a computer (i.e. Make a manual trace of the program): // TestSampleQueue class import java.io.*; import java.lang.*; public class TestSampleQueue { private SampleQueue queue = new SampleQueue(); public void run() throws Exception { queue.enqueue(new Integer(10)); System.out.println(queue.toString()); queue.enqueue(new Integer(5)); System.out.println(queue.toString()); queue.dequeue(); System.out.println(queue.toString()); queue.enqueue(new Integer(15)); System.out.println(queue.toString()); queue.enqueue(new Integer(7)); System.out.println(queue.toString()); queue.dequeue(); System.out.println(queue.toString()); } // end of run method public static void main(String[] args) { TestSampleQueue program; try { program = new TestSampleQueue(); program.run(); } catch ( Exception e ) { e.printStackTrace(); } System.exit(0); } // end of main method } // end of TestSampleQueue class
Assume that the SampleQueue class, with the given code below, is used in the TestSampleQueue that is also shown below. Show the output of the TestSampleQueue. Do the exercise without using a computer (i.e. Make a
manual trace of the
// TestSampleQueue class
import java.io.*;
import java.lang.*;
public class TestSampleQueue {
private SampleQueue<Integer> queue = new SampleQueue<Integer>();
public void run() throws Exception {
queue.enqueue(new Integer(10));
System.out.println(queue.toString());
queue.enqueue(new Integer(5));
System.out.println(queue.toString());
queue.dequeue();
System.out.println(queue.toString());
queue.enqueue(new Integer(15));
System.out.println(queue.toString());
queue.enqueue(new Integer(7));
System.out.println(queue.toString());
queue.dequeue();
System.out.println(queue.toString());
} // end of run method
public static void main(String[] args) {
TestSampleQueue program;
try {
program = new TestSampleQueue();
program.run();
} catch ( Exception e ) {
e.printStackTrace();
}
System.exit(0);
} // end of main method
} // end of TestSampleQueue class
Step by step
Solved in 2 steps