Esempio n. 1
0
        public string SendKeyPress(char key)
        {
            switch (key)
            {
            case var c when Character.IsDigitOrDot(c):
                UpdatedDisplay = Operands.UpdateOperands(c);

                break;

            case var c when Character.IsSymbol(c):
                UpdatedDisplay = DoOperation(c);

                break;

            case var c when Character.IsToggle(c):
                UpdatedDisplay = Operands.ChangeSign();

                break;

            case var c when Character.IsSetZero(c):
                UpdatedDisplay = SetZero();

                break;

            default:        //ignoring other characters and return previous displayed string
                break;
            }


            if (Character.IsInfinity(UpdatedDisplay))
            {
                Operands.Reset();
                UpdatedDisplay = "0";
                return(ERROR);
            }

            return(UpdatedDisplay);
        }