Exemplo n.º 1
0
        public void Run(string[] args)
        {
            cli = new CLI(args);
            cli.Run();


            var arguments = new CLI(args).ReadArguments <CalcArguments>();

            argumentExpression = new ArgumentExpressionReader(arguments);


            calcService = new CalcService(new MathOptions(arguments.ShouldDenyNegative, arguments.LargestNumber, arguments.MaximumNumbers));

            MathExpressionResult mathExpression = null;

            if (argumentExpression.HasArgumentExpression())
            {
                mathExpression = argumentExpression.Get();
            }
            else
            {
                mathExpression = GetExpressionFromConsole();
            }

            var result = calcService.RunExpression(mathExpression.Op, mathExpression.Expression);

            WriteResult(mathExpression, result);
        }
Exemplo n.º 2
0
        public void WriteResult(MathExpressionResult mathExpression, ExpressionResult result)
        {
            Console.WriteLine("Expression: {0}", mathExpression.Expression);
            Console.WriteLine("Results:");

            string valuesString = String.Join <long>(mathExpression.OpChar, result.Values.ToArray());

            Console.WriteLine("{0}={1}", valuesString, result.Result);
        }