//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(); }
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; } } }
//Special Functions private void SQRTButton_MouseClick(object sender, MouseEventArgs e) { string input = SQRTButton.Text; CalculatorState.getInstance().nextState(4, input); textBox1.Text = SpecialOperationState.getInstance().display(); }
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(); }
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); } }
private void ClearButton_MouseClick(object sender, MouseEventArgs e) { CalculatorState.getInstance().nextState(6, null); textBox1.Text = ClearState.getInstance().display(); }
private void ClearAll_MouseClick(object sender, MouseEventArgs e) { CalculatorState.getInstance().nextState(5, null); textBox1.Text = ClearEverythingState.getInstance().display(); }
private void BackspaceButton_MouseClick(object sender, MouseEventArgs e) { CalculatorState.getInstance().nextState(0, null); textBox1.Text = BackspaceState.getInstance().display(); }