Beispiel #1
0
        public static void Main(string[] args)
        {
            IExpression exp1 = new Add(new Value(1), new Value(2));

            IExpression exp2 = new Mul(new Add(new Value(1), new Value(2)), new Value(2));

            IExpression exp3 = new Sub(new Mul(new Add(new Value(1), new Value(2)), new Value(2)), new Value(1));

            Console.WriteLine(exp1.Evaluate());
            Console.WriteLine(exp2.Evaluate());
            Console.WriteLine(exp3.Evaluate());
        }
Beispiel #2
0
        public void Mul_Add_1_And_2_And_3_Return_6()
        {
            IExpression exp2 = new Mul(new Add(new Value(1), new Value(2)), new Value(2));

            Assert.AreEqual(6, exp2.Evaluate());
        }