Esempio n. 1
0
        private void SwitchValues()
        {
            switch (operationStage)
            {
            case OperationStage.EnterFirstOperand:
            {
                SecondOperand.Reset();
                operationStage = OperationStage.EnterSecondOperand;
                break;
            }

            case OperationStage.EnterSecondOperand:
            {
                CalculateResult();
                MoveResultToFirstOperand();
                SecondOperand.Reset();
                operationStage = OperationStage.EnterSecondOperand;
                break;
            }

            case OperationStage.DisplayResult:
            {
                MoveResultToFirstOperand();
                SecondOperand.Reset();
                operationStage = OperationStage.EnterSecondOperand;
                break;
            }
            }
        }
Esempio n. 2
0
        public void ModifyOperand(string commandString)
        {
            if (operationStage == OperationStage.DisplayResult)
            {
                MoveResultToFirstOperand();
            }

            switch (commandString)
            {
            case ".":
            {
                GetCurrentOperandObject().SetHasAPoint(true);
                break;
            }

            case "%":
            {
                GetCurrentOperandObject().DivideBy100();
                break;
            }

            case "+/-":
            {
                GetCurrentOperandObject().Invert();
                break;
            }

            case "C":
            {
                FirstOperand.Reset();
                SecondOperand.Reset();
                ResultOperand.Reset();
                operationStage = OperationStage.EnterFirstOperand;
                break;
            }
            }
        }