diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index fb7f4a8..b589d56 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/.idea/deploymentTargetDropDown.xml b/.idea/deploymentTargetDropDown.xml
new file mode 100644
index 0000000..3064f62
--- /dev/null
+++ b/.idea/deploymentTargetDropDown.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml
new file mode 100644
index 0000000..e1eea1d
--- /dev/null
+++ b/.idea/kotlinc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index bdd9278..9f71c83 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,7 +1,7 @@
-
+
diff --git a/app/src/main/java/meow/sweetbread/lincalc/MainActivity.kt b/app/src/main/java/meow/sweetbread/lincalc/MainActivity.kt
index d6bda8a..b5a9cee 100644
--- a/app/src/main/java/meow/sweetbread/lincalc/MainActivity.kt
+++ b/app/src/main/java/meow/sweetbread/lincalc/MainActivity.kt
@@ -317,30 +317,34 @@ class MainActivity : AppCompatActivity() {
when (token.value) {
"+" -> {
tmp_buf = buffer.dropLast(ext.size - position + 2)
- val res: Token =
- if ((first is Double) and (second is Double))
- Token(
- Tokens.Number,
- (first as Double + second as Double)
- )
- else if ((first is String) and (second is Double))
- Token(
- Tokens.Linear,
- Linear(first as String, second as Double, 0.0)
- )
- else if ((first is Linear) and (second is Double))
- Token(
- Tokens.Linear, Linear(
- (first as Linear).name,
- (first as Linear).add + (second as Double),
- (first as Linear).mul
- )
- )
- else
- Token(
- Tokens.Linear,
- Linear(second as String, first as Double, 0.0)
- )
+ val res: Token = when (first) {
+ is Double -> {
+ when (second) {
+ is Double -> { Token(Tokens.Number, (first + second)) }
+ is String -> { Token(Tokens.Linear, Linear(second, first, 1.0)) }
+ is Linear -> { Token(Tokens.Linear,
+ Linear(second.name, second.add + first, second.mul))
+ }
+ else -> {Token(Tokens.Error, "")}
+ }
+ }
+ is String -> {
+ when (second) {
+ is Double -> { Token(Tokens.Linear, Linear(first, second, 1.0)) }
+ else -> { Token(Tokens.Error, "") }
+ }
+ }
+ is Linear -> {
+ when (second) {
+ is Double -> { Token(Tokens.Linear,
+ Linear(first.name, first.add + second, first.mul))
+ }
+ else -> { Token(Tokens.Error, "") }
+ }
+ }
+ else -> {Token(Tokens.Error, "")}
+ }
+
tmp_buf += res
tmp_buf += buffer.drop(position + 1)
}
@@ -500,7 +504,8 @@ enum class Tokens {
Constant,
Variable,
Linear,
- Quadratic
+ Quadratic,
+ Error
}
class Token(val type: Tokens, val value: Any) {
diff --git a/build.gradle b/build.gradle
index b2ebb1e..906770c 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,6 +1,6 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
- id 'com.android.application' version '7.4.1' apply false
- id 'com.android.library' version '7.4.1' apply false
+ id 'com.android.application' version '8.0.0' apply false
+ id 'com.android.library' version '8.0.0' apply false
id 'org.jetbrains.kotlin.android' version '1.7.20' apply false
}
\ No newline at end of file
diff --git a/gradle.properties b/gradle.properties
index c22da57..bb36cd2 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -21,4 +21,6 @@ kotlin.code.style=official
# resources declared in the library itself and none from the library's dependencies,
# thereby reducing the size of the R class for that library
android.nonTransitiveRClass=true
-android.enableJetifier=true
\ No newline at end of file
+android.enableJetifier=true
+android.defaults.buildfeatures.buildconfig=true
+android.nonFinalResIds=false
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 07bbf9a..2ecd476 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,6 @@
#Wed Nov 16 21:17:09 MSK 2022
distributionBase=GRADLE_USER_HOME
-distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME