Exemple #1
0
 public void enter()
 {
     displayValue[3] = displayValue[2];
     displayValue[2] = displayValue[1];
     displayValue[1] = displayValue[0];
     eventOccurred   = CALCULATION_TYPE.enterOccurred;
 }
Exemple #2
0
 public void subtract()
 {
     displayValue[0] = (Convert.ToDouble(displayValue[1]) - Convert.ToDouble(displayValue[0])).ToString();
     displayValue[1] = displayValue[2];
     displayValue[2] = displayValue[3];
     displayValue[3] = "0";
     eventOccurred   = CALCULATION_TYPE.enterOccurred;
 }
Exemple #3
0
        public void swap()
        {
            double temp = Convert.ToDouble(displayValue[0]);

            displayValue[0] = displayValue[1];
            displayValue[1] = temp.ToString();
            eventOccurred   = CALCULATION_TYPE.calculationOccurred;
        }
Exemple #4
0
 public void clearAll()
 {
     for (int i = 0; i < 4; ++i)
     {
         displayValue[i] = "0";
     }
     eventOccurred = CALCULATION_TYPE.none;
 }
Exemple #5
0
 public void exponent()
 {
     displayValue[0] = (Math.Pow(Convert.ToDouble(displayValue[1]), Convert.ToDouble(displayValue[0]))).ToString();
     displayValue[1] = displayValue[2];
     displayValue[2] = displayValue[3];
     displayValue[3] = "0";
     eventOccurred   = CALCULATION_TYPE.enterOccurred;
 }
Exemple #6
0
 public void buildDisplayValue(char c)
 {
     if (eventOccurred == CALCULATION_TYPE.enterOccurred)
     {
         eventOccurred   = CALCULATION_TYPE.none;
         displayValue[0] = c.ToString();
     }
     else if (eventOccurred == CALCULATION_TYPE.calculationOccurred)
     {
         eventOccurred   = CALCULATION_TYPE.none;
         displayValue[3] = displayValue[2];
         displayValue[2] = displayValue[1];
         displayValue[1] = displayValue[0];
         displayValue[0] = c.ToString();
     }
     else if (displayValue[0][0] == '0' && displayValue[0].Length == 1)
     {
         displayValue[0] = c.ToString();
     }
     else
     {
         displayValue[0] += c.ToString();
     }
 }