public Form1() { InitializeComponent(); stage = stageType.operand1; initCalculator(); clearMemory(); }
private void btnMinus_Click(object sender, EventArgs e) { if (stage == stageType.equals) { firstNum = result.ToString(); } stage = stageType.modifier; addToEquation("-"); }
/* initializes all the data needed */ public void nextStage() { activePlayer = -1; currStageId += 1; if (currStageId < numStages) { currStage = sponsorship.getStage(currStageId); currStageType = (currStage.isCombat()) ? stageType.COMBAT : stageType.TEST; } }
private void btnDecimal_Click(object sender, EventArgs e) { if (stage == stageType.equals) { stage = stageType.operand1; } if (stage == stageType.modifier) { stage = stageType.operand2; } addToEquation("."); }
private void initCalculator() { sign = true; firstNum = "0"; secondNum = "0"; result = 0.0f; stageType temp = stage; stage = stageType.equals; updateDisplay(); stage = temp; }
private void popEquation(int amount = 1) { int number = new int(); stageType temp = stage; if (stage == stageType.operand1) { try { if (amount == -1) { firstNum = "0"; } firstNum = firstNum.Substring(0, firstNum.Length - 1); if (firstNum == null || firstNum.Length == 0) { firstNum = "0"; } } catch (Exception ex) { //do nothing } } else if (stage == stageType.operand2) { try { if (amount == -1) { secondNum = "0"; } secondNum = secondNum.Substring(0, secondNum.Length - 1); if (secondNum == null || secondNum.Length == 0) { secondNum = "0"; } } catch (Exception ex) { //do nothing } } else if (stage == stageType.modifier) { myOperator = ""; } else if (stage == stageType.equals) { initCalculator(); } updateDisplay(); }
private void btnEquals_Click(object sender, EventArgs e) { stage = stageType.equals; updateDisplay(); }