001package iterator.exprtwo;
002import java.util.Iterator;
003import enumeration.Op;
004
005public class Main {
006        public static void main (String[] args) {
007                AbsExpr one = new Const(1);
008                AbsExpr onePtwo = new BinOp (new Const(1), Op.ADD, new Const(2));
009                AbsExpr threeMfour = new BinOp (new Const(3), Op.MUL, new Const(4));
010                AbsExpr 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                for (Iterator<Object> i = n.preorderIterator(); i.hasNext(); )
018                        System.out.print (i.next() + " ");
019                System.out.println ("");
020
021                for (Iterator<Object> i = n.breadthIterator(); i.hasNext(); )
022                        System.out.print (i.next() + " ");
023                System.out.println ("");
024
025                System.out.println ("Value: " + n.evaluate());
026        }
027}