コード例 #1
0
        public string SetInputBuffer()
        {
            if (_StateOfCalculated && _TxtOfLastButton == "=")
            {
                ResetState();
            }

            if (_TxtOfLastButton == "=")
            {
                ResetState();
            }

            if (_StateOperatorInputted)
            {
                _StateOperatorInputted = false;
                _numberInputtingBuffer = new NumberInputtingBuffer();
            }

            _StateOfNumberInputting = true;


            if (_BtnText == "." && _numberInputtingBuffer.GetValue != null && _numberInputtingBuffer.GetValue.Contains("."))
            {
                return(_numberInputtingBuffer.GetValue);
            }

            string inputEcho = _numberInputtingBuffer.Append(_BtnText);

            _inputtingEcho.Clear().Append(inputEcho);

            _TxtOfLastButton = _BtnText;

            return(inputEcho);
        }
コード例 #2
0
 public void ResetState()
 {
     _StateOfNumberInputting = false;
     _StateOfNumberInputted  = false;
     _StateOperatorInputted  = false;
     _StateOfCalculated      = false;
     _TxtOfLastButton        = string.Empty;
     _LastNumber             = 0d;
     _numberInputtingBuffer  = new NumberInputtingBuffer();
     _inputtingEcho          = new StringBuilder();
     _inputtedRecorder       = new StringBuilder();
     _numberStack            = new Stack <double>();
     _operatorSatck          = new Stack <string>();
     _resultStack            = new Stack <double>();
 }