/* http://www.cs.nyu.edu/courses/summer07/G22.2110-001/hw07-java-driver.txt * Rename this file into Driver.java, and the other files for this example * into IntVector.java and IntStack.java. Compile with * javac Driver.java * then run with * java Driver * Enter commands like "push 3", "pop", or "quit". */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Driver { public static void main(String[] args) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); IntStack b = new IntStack(); while (true) { String line = in.readLine(); if (null == line) break; StringTokenizer tokens = new StringTokenizer(line); String command = tokens.nextToken(); if ("push".equals(command)) { int value = Integer.parseInt(tokens.nextToken()); b.push(value); System.out.println("--> void"); } else if ("pop".equals(command)) { int value = b.pop(); System.out.println("--> " + value); } else if ("size".equals(command)) { System.out.println("--> " + b.size()); } else if ("quit".equals(command)) { break; } } } }