Exemplo n.º 1
0
        public override string Equal(string strOperator = "+", bool isEqualSign = false)
        {
            Reset = false;
            if (OperatorClicked && !isEqualSign)
            {
                return(total);
            }
            OperatorClicked = true;
            if (total == null)
            {
                lastOperator = strOperator;
                total        = sOperatorNum;
                sOperatorNum = null;
                //tbDisplayScreen.Text = "0";
                Button_Clear = true;
                return(total);
            }
            if (lastOperator == "" || sOperatorNum == "")
            {
                return(total);
            }
            if (sOperatorNum == "0" && lastOperator == "/")
            {
                Button_Clear = true;
                Reset        = true;
                total        = null;
                return("除数不能为零");
            }

            calculate = operationFactory.createOperate(lastOperator);

            calculate.NumberA = Convert.ToDouble(total);
            calculate.NumberB = Convert.ToDouble(sOperatorNum);
            total             = calculate.GetResult().ToString();

            if (isEqualSign)
            {
                Reset = true;
            }

            lastOperator     = strOperator;
            Button_BackSpace = false;
            Button_Clear     = true;
            return(total);
        }