Source of 7.4.java


  1: // @author Frank M. Carrano, Timothy M. Henry
  2: // @version 5.0
  3: QueueInterface<String> myQueue = new LinkedQueue<>();
  4: myQueue.enqueue("Jada");
  5: myQueue.enqueue("Jess");
  6: myQueue.enqueue("Jazmin");
  7: myQueue.enqueue("Jorge");
  8: myQueue.enqueue("Jamal");

 10: String front = myQueue.getFront(); // Returns "Jada"
 11: System.out.println(front + " is at the front of the queue.");

 13: front = myQueue.dequeue(); // Removes and returns "Jada"
 14: System.out.println(front + " is removed from the queue.");

 16: myQueue.enqueue("Jerry"); // Adds "Jerry"

 18: front = myQueue.getFront(); // Returns "Jess"
 19: System.out.println(front + " is at the front of the queue.");

 21: front = myQueue.dequeue(); // Removes and returns "Jess"
 22: System.out.println(front + " is removed from the queue.");