Ejemplo n.º 1
0
        internal static string SimpleCal(string inputexpress)
        {
            bool   wrong = false;
            string sf    = ReplaceParamers(inputexpress);

            if (sf != null)
            {
                StringCalculatorProvided sc = new StringCalculatorProvided();
                sc.SetCalString(sf);

                double result = sc.GetResult();
                if (sc.IsError())
                {
                    PushToShow("Wrong Input");
                    PushToShow(sc.GetErrorMessage());
                    wrong = true;
                }
                else
                {
                    return(result.ToString());
                }
            }


            PushToShow("表达式错误");


            if (wrong)
            {
                return(null);
            }
            return(null);
        }
Ejemplo n.º 2
0
        public double GetResult()
        {
            if (funcstring == null)
            {
                return(0);
            }

            if (funcstring.Wrong)
            {
                return(0);
            }
            double result = 0;
            StringCalculatorProvided sc = new StringCalculatorProvided();

            sc.SetCalString(funcstring.GetFuncExpressTemp());
            result      = sc.GetResult();
            errormessge = sc.GetErrorMessage();
            return(result);
        }
Ejemplo n.º 3
0
        //直接调用底层的StringCalculator 对象引用,没有经过UIController
        public string GetValue()
        {
            double result = 0;
            string strr   = "0";
            StringCalculatorProvided sc = new StringCalculatorProvided();

            sc.SetCalString(value);

            result = sc.GetResult();
            if (sc.IsError())
            {
                UIController.UIController.PushToShow("Wrong Input: " + express + "  Not Support Parameter Express!Value");
                UIController.UIController.PushToShow(sc.GetErrorMessage());
            }
            else
            {
                strr = result.ToString();
            }
            return(strr);
        }