예제 #1
0
        public Form1()
        {
            InitializeComponent();

            stage = stageType.operand1;
            initCalculator();
            clearMemory();
        }
예제 #2
0
 private void btnMinus_Click(object sender, EventArgs e)
 {
     if (stage == stageType.equals)
     {
         firstNum = result.ToString();
     }
     stage = stageType.modifier;
     addToEquation("-");
 }
예제 #3
0
 /* 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;
     }
 }
예제 #4
0
 private void btnDecimal_Click(object sender, EventArgs e)
 {
     if (stage == stageType.equals)
     {
         stage = stageType.operand1;
     }
     if (stage == stageType.modifier)
     {
         stage = stageType.operand2;
     }
     addToEquation(".");
 }
예제 #5
0
        private void initCalculator()
        {
            sign = true;

            firstNum  = "0";
            secondNum = "0";
            result    = 0.0f;

            stageType temp = stage;

            stage = stageType.equals;
            updateDisplay();
            stage = temp;
        }
예제 #6
0
        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();
        }
예제 #7
0
 private void btnEquals_Click(object sender, EventArgs e)
 {
     stage = stageType.equals;
     updateDisplay();
 }