Example #1
0
 public string Visit(BinaryOperation expression)
 {
     expression._left.Accept(this);
     _expression = _expression + expression._symbol;
     expression._right.Accept(this);
     return(_expression);
 }
Example #2
0
        static void Main()
        {
            IExpression     expression       = new BinaryOperation(new Brackets(new BinaryOperation(new Literal(10), new Literal(2), "*")), new Literal(67), "+");
            IExpression     newExpression    = new BinaryOperation(new Brackets(new BinaryOperation(new Literal(10), new Literal(2), "*")), new Brackets(new BinaryOperation(new Literal(1000), new Literal(500), "/")), "-");
            PrintExpression _printExpression = new PrintExpression();

            expression.Accept(_printExpression);
            Console.WriteLine("Выражение: {0}", _printExpression._expression);

            _printExpression._expression = "";

            newExpression.Accept(_printExpression);
            Console.WriteLine("Выражение: {0}", _printExpression._expression);

            Console.ReadKey();
        }