public void Complex_Expression()
        {
            const int expected = ((3 + 5*6/2) - 8);

            var expression =
                new Substraction(
                    new Addition(
                        new Number(3),
                        new Multiplication(
                            new Number(5),
                            new Division(
                                new Number(6),
                                new Number(2)))),
                    new Number(8));

            AssertExpression(expression, expected);
        }
        public void Test_Complex_Expression()
        {
            const string expected = "( ( 3 + 5 * 2 / 6 ) - 8 )";

            var expression =
                new Substraction(
                    new Addition(
                        new Number(3),
                        new Multiplication(
                            new Number(5),
                            new Division(
                                new Number(2),
                                new Number(6)))),
                    new Number(8));

            AssertExpression(expression, expected);
        }
Пример #3
0
        public static void Visitor()
        {
            //"( ( 3 + 5 * 2 / 6 ) - 8 )"
            var expression =
                new Substraction(
                    new Addition(
                        new Number(3),
                        new Multiplication(
                            new Number(5),
                            new Division(
                                new Number(2),
                                new Number(6)))),
                    new Number(8));
            var visitor = new ToTextVisitor();
            expression.Accpet(visitor);
            string expressionText = visitor.GetResult();

            Console.WriteLine(expressionText);
        }
Пример #4
0
 public void VisitSubstraction(Substraction expression)
 {
     VisitBinary(
         (left, right) => left - right);
 }
        public void Simple_Substraction()
        {
            const int expected = (6 - 2);

            var expression =
                new Substraction(
                    new Number(6),
                    new Number(2));

            AssertExpression(expression, expected);
        }
 public void VisitSubstraction(Substraction expression)
 {
     VisitBinary("( {0} - {1} )");
 }
 public void VisitSubstraction(Substraction expression)
 {
     VisitBinary(
         (left, right) => left - right);
 }
 public void VisitSubstraction(Substraction expression)
 {
     VisitBinary("( {0} - {1} )");
 }