import java.util.ArrayList; import java.util.Scanner; public class Postfix { // use evalStack for the evaluation of the postfix expression in line // implement evalStack with the pop and push methods private ArrayList evalStack = new ArrayList(); // when scanning a next Token, put it in nextToken private String nextToken; // scLine is the scanner that gets the input line private Scanner scLine; // debug is used to report progress private boolean debug; /* constructor * set instance variable debug * create new scanner with String line and assign to scLine */ public Postfix(String line, boolean debug){ this.debug = debug; scLine = new Scanner(line); } /* * push Integer i on evalStack * In debug mode print "push: " + pushed value */ private void push(Integer i){ } /* * pop Integer from evalStack * If evalStack empty, return null * In debug mode print "pop: " + popped value */ private Integer pop(){ return null; } /* * evaluate the postfix expression in scLine * when encountering an Integer, push it on the evalStack * when encountering an operator, * pop two values off the evalStack (right, then left) * perform the operation, and push the result on the evalStack * at the end of the expression, * pop the result off the stack and return it * * scLine either contains an empty line, or a valid postfix expression */ public Integer eval(){ return null; } }