public void Visit(AdditionalExpression ae)
 {
     sb.Append("(");
     ae.Left.Accept(this);
     sb.Append("+");
     ae.Right.Accept(this);
     sb.Append(")");
 }
        public void Visit(AdditionalExpression ae)
        {
            ae.Left.Accept(this);
            var a = Result;

            ae.Right.Accept(this);
            var b = Result;

            Result = a + b;
        }
        static void Main(string[] args)
        {
            var e = new AdditionalExpression(
                new DoubleExpression(1),
                new AdditionalExpression(
                    new DoubleExpression(3),
                    new DoubleExpression(4)));
            var printer = new ExpressionPrinter();

            printer.Visit(e);
            WriteLine(printer);

            var calculator = new ExpressionCalculator();

            calculator.Visit(e);
            WriteLine($"{printer} = {calculator}");
            ReadKey();
        }