Example #1
0
 };                                                                                     //无左括号
 public override string Equal(string strOperator = "+", bool isEqualSign = false)
 {
     if (!isEqualSign)
     {
         if (canAddOperator(strOperator))
         {
             while (RightInput.Length > 0 && (RightInput.IndexOf('.') != -1 &&
                                              sOperatorNum[sOperatorNum.Length - 1] == '0' ||
                                              RightInput[RightInput.Length - 1] == '.'))//删除多余的"."和"0"
             {
                 sOperatorNum = sOperatorNum.Substring(0, sOperatorNum.Length - 1);
                 RightInput   = RightInput.Substring(0, RightInput.Length - 1);
             }
             sOperatorNum += strOperator;
             RightInput    = "";
         }
     }
     else
     {
         if (!isExpressionHolds())
         {
             return(sOperatorNum);
         }
         var pts = new Parenthesis();//之后版本中用factory模式代替
         pts.Expression = sOperatorNum;
         sOperatorNum   = pts.CalculatePostfixExp();
     }
     return(sOperatorNum);
 }
Example #2
0
 public override string SetPoint()
 {
     if (RightInput.IndexOf(".") == -1)
     {
         if (RightInput.Length != 0)
         {
             RightInput   += ".";
             sOperatorNum += ".";
         }
     }
     return(sOperatorNum);
 }