001package iterator.exprone; 002import java.util.Iterator; 003import enumeration.Op; 004 005public class Main { 006 public static void main (String[] args) { 007 Expr one = new Const(1); 008 Expr onePtwo = new BinOp (new Const(1), Op.ADD, new Const(2)); 009 Expr threeMfour = new BinOp (new Const(3), Op.MUL, new Const(4)); 010 Expr m = new BinOp (onePtwo, Op.SUB, threeMfour); 011 Expr n = new BinOp (m, Op.DIV, new Const(5)); 012 013 for (Iterator<Object> i = n.postorderIterator(); i.hasNext(); ) 014 System.out.print (i.next() + " "); 015 System.out.println (""); 016 017 System.out.println ("Value: " + n.evaluate()); 018 } 019}