Esempio n. 1
0
        private static void Main()
        {
            var calculatorItems = new CalculatorItems();

            try
            {
                Console.Write("Kérem az első számot: ");
                calculatorItems.firstNumberText = Console.ReadLine();

                Console.Write("Kérem a 2. számot: ");
                calculatorItems.secondNumberText = Console.ReadLine();

                Console.Write("Kérem az operátort: ");
                calculatorItems.operationText = Console.ReadLine();

                Console.WriteLine();

                var returnedCalculatorItems = new CalculatorExecutor(calculatorItems).Run();

                Console.Write($"Eredmény: {returnedCalculatorItems.result}");
            }
            catch (Exception exception)
            {
                Console.Write(exception.Message);
            }
            Console.ReadKey();
        }
Esempio n. 2
0
 /// <summary>
 /// Calls the InputHander cleaning.
 /// Calls the CalculateAction execute method.
 /// The result is returned in the CalculatorItems.result field.
 /// </summary>
 public CalculatorItems Run()
 {
     try
     {
         var inputHandler = new InputHandler(calculatorItems);
         this.calculatorItems = new CalculateAction(inputHandler.CleanCalculatorItems()).Execute();
     }
     catch (Exception exception)
     {
         throw new Exception(exception.Message);
     }
     return(this.calculatorItems);
 }
Esempio n. 3
0
 public CalculatorExecutor(CalculatorItems receivedCalculatorItems)
 {
     this.calculatorItems = receivedCalculatorItems;
 }
Esempio n. 4
0
 public CalculateAction(CalculatorItems receivedCalculatorItems)
 {
     calculatorItems = receivedCalculatorItems;
 }
Esempio n. 5
0
 /// <summary>
 /// Validates the inputs and converts them to double and char
 /// </summary>
 /// <param name="receivedCalculatorItems"></param>
 public InputHandler(CalculatorItems receivedCalculatorItems)
 {
     calculatorItems = receivedCalculatorItems;
 }