import java.util.Stack;
import SimpleOutput;


public class stackExample {
    // class provides a framework for a simple stack example
    // The following steps follow work done in a Scheme lab on Stacks

    public static void main (String args []) {

    // Section 0:  Create objects needed later
    Stack magPile = new Stack();
    Stack billPile = new Stack();
    SimpleOutput out = new SimpleOutput();
    out.println ("Section 0 done");
    out.println ("Creation of objects magPile, billPile, and out completed");

    // Section 1:  push objects onto billPile
    billPile.push ("mortgage");
    billPile.push ("doctor's bill");
    billPile.push ("credit card");
    out.println ("Section 1 done");
    out.println ("Check if billPile is empty:  " + billPile.isEmpty());
    out.println ("Check if magPile is empty:  "  +  magPile.isEmpty());

    // Section 2:  push objects onto magPile
    magPile.push ("Communications of the ACM - April 1997");
    magPile.push ("CS Education Bulletin - Spring 1998");
    out.println ("Section 2 done");
    //Note:  top not a method of built-in class Stack
    //       Replace top() by the appropriate method in what follows!
    //out.println ("Check top of billPile:  " + billPile.top());
    //out.println ("Check top of magPile:  "  +  magPile.top());
 
    // Section 3:  pop and print objects from billPile
    out.println ("Top item removed from billPile:  " + billPile.pop());
    out.println ("Check if billPile is empty:  " + billPile.isEmpty());
    out.println ("Top item removed from billPile:  " + billPile.pop());
    out.println ("Check if billPile is empty:  " + billPile.isEmpty());
    out.println ("Top item removed from billPile:  " + billPile.pop());
    out.println ("Check if billPile is empty:  " + billPile.isEmpty());
    // billPile empty here, so next line causes program to terminate
    out.println ("Top item removed from billPile:  " + billPile.pop());
    }
}

