public void enter() { displayValue[3] = displayValue[2]; displayValue[2] = displayValue[1]; displayValue[1] = displayValue[0]; eventOccurred = CALCULATION_TYPE.enterOccurred; }
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; }
public void swap() { double temp = Convert.ToDouble(displayValue[0]); displayValue[0] = displayValue[1]; displayValue[1] = temp.ToString(); eventOccurred = CALCULATION_TYPE.calculationOccurred; }
public void clearAll() { for (int i = 0; i < 4; ++i) { displayValue[i] = "0"; } eventOccurred = CALCULATION_TYPE.none; }
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; }
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(); } }