Add of a simple check in order to fix the division-by-zero bug

This commit is contained in:
AlbertoPellitteri 2021-05-12 09:32:29 +02:00
parent d09aa44f91
commit 2f46e77ba3
1 changed files with 4 additions and 0 deletions

View File

@ -147,6 +147,10 @@ class CalculatorImpl(calculator: Calculator, private val context: Context) {
secondValue = getSecondValue() secondValue = getSecondValue()
calculateResult() calculateResult()
if (lastOperation == DIVIDE && secondValue == 0.0){
lastKey = DIGIT
return
}
lastKey = EQUALS lastKey = EQUALS
} }