//PriorityQueueGrader.java

/**
 * Tests an implementation of a PriorityQueue for correctness.
 *
 * @author Zach Tomaszewski
 * @version 12 Apr 2005
 */
public class PriorityQueueGrader {

  /**
   * Runs a number of tests of a Queue, printing the expected results and actual
   * results to the screen.
   */
  public static void main(String[] args) {

    //System.out.println("Testing basic queue functions first.");
    System.out.println("Creating a new queue.");
    Queue q = new PriorityQueue();

    try {
      System.out.print("A new queue is empty [true]: ");
      System.out.println(q.empty() + "");
      System.out.println("Adding 10.");
      q.enqueue(new Integer(10));
      System.out.println("Adding 20.");
      q.enqueue(new Integer(20));
      System.out.println("Adding 8, 12, 10, 30, 3.");
      q.enqueue(new Integer(8));
      q.enqueue(new Integer(12));
      q.enqueue(new Integer(10));
      q.enqueue(new Integer(30));
      q.enqueue(new Integer(3));

      System.out.println("Printing the list (assuming a toString(). Optional.)");
      System.out.print("Heap = [3, 10, 8, 20, 12, 30, 10]: "); 
      System.out.println(q.toString());
      System.out.print("Top element [3]: ");
      System.out.println(q.front());
      System.out.print("size [7]: ");
      System.out.println(q.size());
      System.out.print("empty? [false]: ");
      System.out.println(q.empty());

      System.out.print("Removing 3 items [3, 8, 10]: ");
      for (int i = 0; i < 3; i++) {
        System.out.print(q.dequeue() + " ");
      }
      System.out.print("\nsize [4]: ");
      System.out.println(q.size());

      System.out.print("Removing the rest [10, 12, 20, 30]: ");
      while (!q.empty()) {
        System.out.print(q.dequeue() + " ");
      }
      System.out.print("\nempty? [true]: ");
      System.out.println(q.empty());

   }catch (QueueEmptyException qee) {
     System.out.println("You threw an unnecessary QueueEmptyException.");
   }catch (QueueFullException qfe) {
     System.out.println("You threw an unnecessary QueueFullException.");
   }
    
   System.out.println("DONE!"); 
  }

}
