public static void Test() { Context context = new Context(); context.SetValue("x", 2); context.SetValue("y", 5); context.SetValue("z", 7); IExpression expression = new SubtractExpression( new AddExpression( new NumberExpression("x"), new NumberExpression("z")), new NumberExpression("y") ); Console.WriteLine($"{context.GetValue("x")} + {context.GetValue("z")} - {context.GetValue("y")} = {expression.Interpret(context)}"); }
public override bool Interpret(Context context) { return(context.GetValue(name)); }
public int Interpret(Context context) { return(context.GetValue(Name)); }