import java.util.Scanner; /** Driver.java -- Let's test some queue operations. */ public class Driver { public static void main(String [] args) { LinkedListQueue q = new LinkedListQueue(); Scanner kbd = new Scanner(System.in); System.out.println("Enter queue commands (e)nqueue, (d)equeue, (s)ize " + "(q)uit"); // Keep reading commands from user until they want to quit. while (true) { String command = kbd.nextLine(); System.out.println("You entered " + command); char firstChar = command.charAt(0); if (firstChar == 'q') break; // When enqueuing, we assume that the string follows begins // with the 3rd character, i.e. after 'e' and a space. else if (firstChar == 'e') q.enqueue(command.substring(2)); else if (firstChar == 'd') q.dequeue(); else if (firstChar == 's') System.out.println("size = " + q.size()); System.out.println("\nQueue contains:\n" + q); System.out.print("enter command: "); } } }