예제 #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Give me some Numbers with some +'s between them.");
            var input     = Console.ReadLine();
            var calculate = new CalculationEngine().DoMath(input);

            Console.WriteLine($"Your answer is {calculate}.  Press Enter to close.");
            Console.ReadLine();
        }
예제 #2
0
        static void Main(string[] args)
        {
            var calculator = new CalculationEngine();

            Console.WriteLine("Give me an addition problem, please");
            var input = Console.ReadLine();

            try
            {
                var result = calculator.DoMath(input);
                Console.WriteLine($"The result of your problem is {result}");
            }
            catch (InvalidInputException)
            {
                Console.WriteLine("This is an invalid input");
            }
        }
예제 #3
0
        static void Main(string[] args)
        {
            var calculator = new CalculationEngine();

            Console.WriteLine("Give me an addition problem");
            var input = Console.ReadLine();

            try
            {
                var result = calculator.DoMath(input);
                Console.WriteLine($"The result of your problem is {result}.");
            }
            catch (InvalidCastException ex)
            {
                Console.WriteLine(ex.Message);
            }
            Console.ReadLine();
        }