remove everything related to factorials, we dont even have it
This commit is contained in:
parent
dc97c40b70
commit
ae69401aa7
5 changed files with 3 additions and 35 deletions
|
@ -129,11 +129,6 @@ class CalculatorImpl(calculator: Calculator, val context: Context) {
|
|||
calculateResult()
|
||||
}
|
||||
|
||||
private fun handleFactorial() {
|
||||
baseValue = getDisplayedNumberAsDouble()
|
||||
calculateResult()
|
||||
}
|
||||
|
||||
private fun calculateResult(update: Boolean = true) {
|
||||
if (update) {
|
||||
updateFormula()
|
||||
|
@ -185,7 +180,7 @@ class CalculatorImpl(calculator: Calculator, val context: Context) {
|
|||
handlePercent()
|
||||
lastKey = tempOp
|
||||
lastOperation = tempOp
|
||||
} else if (lastKey == DIGIT && operation != ROOT && operation != FACTORIAL) {
|
||||
} else if (lastKey == DIGIT && operation != ROOT) {
|
||||
handleResult()
|
||||
if (inputDisplayedFormula.last() != '+' &&
|
||||
inputDisplayedFormula.last() != '-' &&
|
||||
|
@ -205,9 +200,6 @@ class CalculatorImpl(calculator: Calculator, val context: Context) {
|
|||
if (operation == ROOT) {
|
||||
handleRoot()
|
||||
resetValue = false
|
||||
} else if (operation == FACTORIAL) {
|
||||
handleFactorial()
|
||||
resetValue = false
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -318,7 +310,6 @@ class CalculatorImpl(calculator: Calculator, val context: Context) {
|
|||
PERCENT -> "%"
|
||||
POWER -> "^"
|
||||
ROOT -> "√"
|
||||
FACTORIAL -> "!"
|
||||
else -> ""
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ const val ROOT = "root"
|
|||
const val DECIMAL = "decimal"
|
||||
const val CLEAR = "clear"
|
||||
const val RESET = "reset"
|
||||
const val FACTORIAL = "factorial"
|
||||
|
||||
const val NAN = "NaN"
|
||||
const val ZERO = "zero"
|
||||
|
|
|
@ -86,7 +86,7 @@ class MyWidgetProvider : AppWidgetProvider(), Calculator {
|
|||
|
||||
override fun onReceive(context: Context, intent: Intent) {
|
||||
when (val action = intent.action) {
|
||||
DECIMAL, ZERO, ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, EQUALS, CLEAR, RESET, PLUS, MINUS, MULTIPLY, DIVIDE, PERCENT, POWER, ROOT, FACTORIAL -> myAction(action, context)
|
||||
DECIMAL, ZERO, ONE, TWO, THREE, FOUR, FIVE, SIX, SEVEN, EIGHT, NINE, EQUALS, CLEAR, RESET, PLUS, MINUS, MULTIPLY, DIVIDE, PERCENT, POWER, ROOT -> myAction(action, context)
|
||||
else -> super.onReceive(context, intent)
|
||||
}
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ class MyWidgetProvider : AppWidgetProvider(), Calculator {
|
|||
EQUALS -> calc!!.handleEquals()
|
||||
CLEAR -> calc!!.handleClear()
|
||||
RESET -> calc!!.handleReset()
|
||||
PLUS, MINUS, MULTIPLY, DIVIDE, PERCENT, POWER, ROOT, FACTORIAL -> calc!!.handleOperation(action)
|
||||
PLUS, MINUS, MULTIPLY, DIVIDE, PERCENT, POWER, ROOT -> calc!!.handleOperation(action)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
package com.simplemobiletools.calculator.operation
|
||||
|
||||
import com.simplemobiletools.calculator.operation.base.Operation
|
||||
import com.simplemobiletools.calculator.operation.base.UnaryOperation
|
||||
import java.math.BigDecimal
|
||||
|
||||
class FactorialOperation(value: BigDecimal) : UnaryOperation(value), Operation {
|
||||
|
||||
override fun getResult(): BigDecimal {
|
||||
return if (value.compareTo(BigDecimal.ZERO) == 0 || value.compareTo(BigDecimal.ONE) == 0 ){
|
||||
BigDecimal.ONE
|
||||
} else{
|
||||
var result = BigDecimal.ONE
|
||||
val base = value.toInt()
|
||||
for(i in 1..base){
|
||||
result = result.multiply(BigDecimal(i))
|
||||
}
|
||||
result
|
||||
}
|
||||
}
|
||||
}
|
|
@ -15,7 +15,6 @@ object OperationFactory {
|
|||
PERCENT -> PercentOperation(baseValue, secondValue)
|
||||
POWER -> PowerOperation(baseValue, secondValue)
|
||||
ROOT -> RootOperation(baseValue)
|
||||
FACTORIAL -> FactorialOperation(baseValue)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue