Merge pull request #53 from ensozos/Issue#28

Confusing behaviour after calculating a square root #28
This commit is contained in:
Tibor Kaputa 2018-01-06 13:03:14 +01:00 committed by GitHub
commit 832a2b50d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 3 deletions

View File

@ -92,6 +92,11 @@ class CalculatorImpl(calculator: Calculator, val context: Context) {
mBaseValue = getDisplayedNumberAsDouble()
}
private fun handleRoot() {
mBaseValue = getDisplayedNumberAsDouble()
calculateResult()
}
private fun calculateResult() {
if (!mIsFirstOperation) {
updateFormula()
@ -107,15 +112,18 @@ class CalculatorImpl(calculator: Calculator, val context: Context) {
}
fun handleOperation(operation: String) {
if (lastKey == DIGIT)
if (lastKey == DIGIT && operation != ROOT)
handleResult()
mResetValue = true
lastKey = operation
mLastOperation = operation
if (operation == ROOT)
calculateResult()
if (operation == ROOT) {
handleRoot()
mResetValue = false
}
}
fun handleClear() {