mirror of
https://github.com/SimpleMobileTools/Simple-Calculator.git
synced 2025-06-05 21:49:13 +02:00
simplifying the zero division check a bit
This commit is contained in:
@@ -58,18 +58,11 @@ class CalculatorImpl(calculator: Calculator, val context: Context) {
|
|||||||
val sign = getSign(lastOperation)
|
val sign = getSign(lastOperation)
|
||||||
|
|
||||||
when {
|
when {
|
||||||
sign == "√" -> {
|
sign == "√" -> setFormula(sign + first)
|
||||||
setFormula(sign + first)
|
sign == "!" -> setFormula(first + sign)
|
||||||
}
|
|
||||||
sign == "!" -> {
|
|
||||||
setFormula(first + sign)
|
|
||||||
}
|
|
||||||
sign.isNotEmpty() -> {
|
sign.isNotEmpty() -> {
|
||||||
if (secondValue == 0.0 && sign == "/") {
|
if (secondValue == 0.0 && sign == "/") {
|
||||||
Toast.makeText(
|
context.toast(context.getString(R.string.formula_divide_by_zero_error))
|
||||||
context,
|
|
||||||
context.getString(R.string.formula_divide_by_zero_error),
|
|
||||||
Toast.LENGTH_SHORT).show()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setFormula(first + sign + second)
|
setFormula(first + sign + second)
|
||||||
|
Reference in New Issue
Block a user