Esempio n. 1
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));
        }
Esempio n. 2
0
 /// <summary>
 /// 解释操作.
 /// </summary>
 /// <param name="ctx"></param>
 /// <returns></returns>
 public override bool interpret(Context ctx)
 {
     return left.interpret(ctx) && right.interpret(ctx);
 }
Esempio n. 3
0
 /// <summary>
 /// Given a BooleanExp object denoting a term, this method interprets this term relative to a Context object.
 /// 
 /// 以环境类为准,本方法解释给定的任何一个表达式.
 /// </summary>
 /// <param name="ctx"></param>
 /// <returns></returns>
 public abstract bool interpret(Context ctx);
Esempio n. 4
0
 /// <summary>
 /// 解释操作.
 /// </summary>
 /// <param name="ctx"></param>
 /// <returns></returns>
 public override bool interpret(Context ctx)
 {
     return ctx.lookup(this);
 }
Esempio n. 5
0
 /// <summary>
 /// 解释操作.
 /// </summary>
 /// <param name="ctx"></param>
 /// <returns></returns>
 public override bool interpret(Context ctx)
 {
     return value;
 }
Esempio n. 6
0
 /// <summary>
 /// 解释操作.
 /// </summary>
 /// <param name="ctx"></param>
 /// <returns></returns>
 public override bool interpret(Context ctx)
 {
     return !exp.interpret(ctx) ;
 }