package interpreter;
public class Expression1 {
/**
* @param args
*/
public static void main
(String[] args
) {
// Часть 1:
BooleanExp expression;
VariableExp x = new VariableExp("X");
VariableExp y = new VariableExp("Y");
expression = new OrExp(
new AndExp(new Constant(true), x),
new AndExp(y, new NotExp(x))
);
context.Assign(x, false);
context.Assign(y, true);
boolean result = expression.Evaluate(context);
// Часть 2: замена значения y
NotExp not_z = new NotExp(z) ;
BooleanExp replacement = expression.Replace("Y", not_z);
context.Assign(z, true);
result = replacement.Evaluate(context);
}
}