Exemple #1
0
        public static string ComputeResults(string input)
        {
            try
            {
                if (!IsInputValid(input))
                {
                    return("ERROR");
                }

                double[] arguments      = GetArguments(input);
                string   operatorSymbol = GetSingleOperatorSymbol(input);
                BinaryOperator <double> binaryOperator = BinaryOperatorFactory.Create(operatorSymbol);

                double operationResult = binaryOperator.Operate(arguments[0], arguments[1]);

                string resultString = operationResult.ToString();

                return(resultString.Substring(0, System.Math.Min(resultString.Length, 10)));
            }
            catch (System.Exception e)
            {
                string s = e.ToString();
                return("EXCEPTION");
            }
        }