1 3 package org.jmock.examples.calculator; 4 5 import java.util.HashMap ; 6 7 8 public class SimpleEnvironment implements Environment 9 { 10 public HashMap variables = new HashMap (); 11 12 13 public Expression getVariable( String name ) throws CalculatorException { 14 if (variables.containsKey(name)) { 15 return (Expression)variables.get(name); 16 } 17 throw new CalculatorException("variable \"" + name + "\" not defined"); 18 } 19 20 public void setVariable( String name, Expression expression ) { 21 variables.put(name, expression); 22 } 23 } 24 | Popular Tags |