//StackGrader.java

import java.util.EmptyStackException;

/**
 * Tests an implementation of a Stack for correctness.
 *
 * @author Zach Tomaszewski
 * @version 15 Oct 2004
 */
public class StackGrader {

  /**
   * Runs a number of tests of a stack, printing the expected results and actual
   * results to the screen.
   */
  public static void main(String[] args) {
    System.out.println("Creating a new stack.");
    Stack stack = new MyStack();
    System.out.print("A new stack is empty [true]: ");
    System.out.println(stack.empty() + "");
    System.out.println("Pushing 'one'.");
    stack.push("one");
    System.out.println("Pushing 'two'.");
    stack.push("two");
    System.out.println("Pushing 'three'.");
    stack.push("three");
    System.out.println("Printing the list (assuming a working toString())");
    System.out.println("[TOP> three, two, one]: "); 
    System.out.println(stack.toString());

    System.out.print("Popping. [three]: ");
    System.out.println(stack.pop());
    System.out.print("Peeking. [two]: ");
    System.out.println(stack.peek() + "");    
    System.out.print("Popping. [two]: ");
    System.out.println(stack.pop());
    System.out.print("Stack is empty? [false]: ");
    System.out.println(stack.empty() + "");
    System.out.println("Clearing/popAll stack.");
    stack.popAll();
    System.out.print("Stack is empty? [true]: ");
    System.out.println(stack.empty() + "");
    
    try{    
      System.out.print("Peeking at empty stack [EmptyStackException?]: ");
      System.out.println("" + stack.peek());
    }catch (EmptyStackException ese) {
      System.out.println("EmptyStackException");
    }
    try{    
      System.out.print("Popping empty stack [EmptyStackException?]: ");
      System.out.println("" + stack.pop());
    }catch (EmptyStackException ese) {
      System.out.println("EmptyStackException");
    }
  }

}
