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; }
void CreateOperators() { // Only one of each operation Token needs to be created opAdd = new Add(workStack); opSubtract = new Subtract(workStack); opMultiply = new Multiply(workStack); opDivide = new Divide(workStack); opPower = new Power(workStack); opBracket = new Bracket(); opUnaryMinus = new UnaryMinus(workStack); opUnaryPlus = new UnaryPlus(); opSqrt = new Sqrt(workStack); opSin = new Sin(workStack); opCos = new Cos(workStack); opTan = new Tan(workStack); opLog = new Log(workStack); opAsin = new Asin(workStack); opAcos = new Acos(workStack); opAtan = new Atan(workStack); functions = new Dictionary<string, Function> { {"sqr", opSqrt }, {"sin", opSin }, {"cos", opCos }, {"tan", opTan }, {"log", opLog }, {"asin", opAsin }, {"acos", opAcos }, {"atan", opAtan } }; binaryOperators = new Dictionary<char, BinaryOperator> { {'+', opAdd }, {'-', opSubtract }, {'*', opMultiply }, {'/', opDivide }, {'^',opPower } }; }