Пример #1
0
        //Operator State
        private void DigitPeriod_Button_MouseClick(object sender, MouseEventArgs e)
        {
            string input = DigitPeriod_Button.Text;

            CalculatorState.getInstance().nextState(1, input);
            textBox1.Text = CalculationState.getInstance().display();
        }
Пример #2
0
 protected void readOp(String input)
 {
     if (op == "")
     {
         op = input;
         isOperand1Complete = true;
         if (isCalculationComplete)
         {
             operand2 = "0";
             isCalculationComplete = false;
             isOperand2Complete    = false;
         }
     }
     else
     {
         if (!isCalculationComplete && isCalculationButtonPressed)
         {
             CalculatorState.getInstance().nextState(3, null);
         }
         op = input;
         isOperand1Complete = true;
         if (isCalculationComplete)
         {
             operand2 = "0";
             isCalculationComplete = false;
             isOperand2Complete    = false;
         }
     }
 }
Пример #3
0
        //Special Functions
        private void SQRTButton_MouseClick(object sender, MouseEventArgs e)
        {
            string input = SQRTButton.Text;

            CalculatorState.getInstance().nextState(4, input);
            textBox1.Text = SpecialOperationState.getInstance().display();
        }
Пример #4
0
        private void Digit7_Button_Click(object sender, EventArgs e)
        {
            string input = Digit7_Button.Text;

            CalculatorState.getInstance().nextState(1, input);
            textBox1.Text = CalculationState.getInstance().clearScreen();
            textBox1.Text = CalculationState.getInstance().display();
        }
Пример #5
0
        public CalculatorState nextState(int state, string input)
        {
            switch (state)
            {
            case 0:
                back.enter();
                cal = back;
                return(cal);

            case 1:
                digit.enter(input);
                cal = digit;
                return(cal);

            case 2:
                opr.enter(input);
                cal = opr;
                return(cal);

            case 3:
                isCalculationButtonPressed = true;
                cs.enter();
                cal = cs;
                return(cal);

            case 4:
                sop.enter(input);
                cal = sop;
                return(cal);

            case 5:
                ces.enter();
                cal = ces;
                return(cal);

            case 6:
                clear.enter();
                cal = clear;
                return(cal);

            default:
                return(cal);
            }
        }
Пример #6
0
 private void ClearButton_MouseClick(object sender, MouseEventArgs e)
 {
     CalculatorState.getInstance().nextState(6, null);
     textBox1.Text = ClearState.getInstance().display();
 }
Пример #7
0
 private void ClearAll_MouseClick(object sender, MouseEventArgs e)
 {
     CalculatorState.getInstance().nextState(5, null);
     textBox1.Text = ClearEverythingState.getInstance().display();
 }
Пример #8
0
 private void BackspaceButton_MouseClick(object sender, MouseEventArgs e)
 {
     CalculatorState.getInstance().nextState(0, null);
     textBox1.Text = BackspaceState.getInstance().display();
 }