package patronInterpreter; import java.util.ArrayList; import java.util.Iterator; //esta clase seria el cliente public class Main { public static void main(String[] args) { String roman = "MCMXXVIII"; Context context = new Context(roman); //Construye el árbol sintáctico ArrayList tree = new ArrayList(); tree.add(new ThousandExpression()); tree.add(new HundredExpression()); tree.add(new TenExpression()); tree.add(new OneExpression()); // Interpretar: recorre todas las Expresiones del árbol. for (Iterator it = tree.iterator(); it.hasNext();){ Expression exp = (Expression)it.next(); exp.interpret(context); } System.out.println(roman + " = " + Integer.toString(context.getOutput())); } }