@Override public void calculate() { if (selectedOperation == null) { // ... nothing to do: insufficient data for calculation. } else { final BigDecimal result; final BigDecimal arg2 = BigDecimalUtils.stringToBigDecimal(currentArgumentInput, locale); if (selectedOperation.isUnary()) { result = getSimpleCalculatorFacade().calculate(arg2, selectedOperation); } else { result = getSimpleCalculatorFacade().calculate(arg1, arg2, selectedOperation); } selectedOperation = null; currentArgumentInput = BigDecimalUtils.bigDecimalToString(result, locale); currentArgumentInputFinished = true; } }
@Override public void selectMathOperation(final EMathOperation mathOperation) { selectedOperation = mathOperation; arg1 = BigDecimalUtils.stringToBigDecimal(currentArgumentInput, locale); currentArgumentInputFinished = true; if (mathOperation.isUnary()) { calculate(); } }