Ejemplo n.º 1
0
 public Input()
 {
     add = new Addition();
     minus = new Subtraction();
     mult = new Multiply();
     div = new Division();
 }
Ejemplo n.º 2
0
 public CalculatorBody()
 {
     this.sum = new Addition();
     this.difference = new Subtraction();
     this.product = new Multiplication();
     this.quotient = new Division();
     this.exponent = new Exponentiation();
     this.sqrt = new SquareRoot();
     this.input = new UserInputOutput();
 }
Ejemplo n.º 3
0
        public decimal Calculate(string calculate, decimal num1, decimal num2)
        {
            //int first = Convert.ToInt32(num1);
            //int second = Convert.ToInt32(num2);

            switch (calculate)
            {
                case "1":
                    Addition addition = new Addition();
                    answer = addition.AddThese(num1, num2);
                    Console.WriteLine("Your answer is: " + answer);
                    break;
                case "2":
                    Subtraction subtraction = new Subtraction();
                    answer = subtraction.SubtractThese(num1, num2);
                    Console.WriteLine("Your answer is: " + answer);
                    break;
                case "3":
                    Multiply multiply = new Multiply();
                    answer = multiply.MultiplyThese(num1, num2);
                    Console.WriteLine("Your answer is: " + answer);
                    break;
                case "4":
                    Divide divide = new Divide();
                    answer = divide.DivideThese(num1, num2);
                    Console.WriteLine("Your answer is: " + answer);
                    break;
                case "5":
                    Exponential exponential = new Exponential();
                    exponential.ExponentThese(num1, num2);
                    break;
                default:
                    Console.WriteLine("Not a valid choice!");
                    break;
            }
            return answer;
        }