Ejemplo n.º 1
0
        public bool lookup(Variable var)
        {
            if (!map.ContainsKey(var))
            {
                throw new ArgumentException();
            }

            return map[var];
        }
Ejemplo n.º 2
0
        public static void ShowDemo()
        {
            Console.WriteLine("===== 布尔类型解释的 演示 (From Java与模式 54章) =====");

            ctx = new Context();

            Variable x = new Variable("x");
            Variable y = new Variable("y");
            Constant c = new Constant(true);

            ctx.assign(x, false);
            ctx.assign(y, true);

            exp = new Or(new And(c, x), new And(y, new Not(x)));
            Console.WriteLine("x = " + x.interpret(ctx));
            Console.WriteLine("y = " + y.interpret(ctx));
            Console.WriteLine(exp.ToString() + " = " + exp.interpret(ctx));
        }
Ejemplo n.º 3
0
 public void assign(Variable var, bool value)
 {
     map.Add(var, value);
 }