Skip to content

Commit

Permalink
"Error!"
Browse files Browse the repository at this point in the history
  • Loading branch information
Hummel009 committed Jan 23, 2024
1 parent 692e6d7 commit 7bb8589
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
8 changes: 4 additions & 4 deletions appJava/src/main/java/hummel/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public class Main {
private static final int BUTTON_UNARY_MINUS_ID = 23;

private static final int DEFAULT_CAPACITY = 100;
private static final String ERROR = "Error!";

private static final List<String> STORAGE = new ArrayList<>();
private static final int[] FACTORIAL = new int[]{1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600};
Expand Down Expand Up @@ -83,7 +84,6 @@ public static void main(String[] args) {
}

private static class WndProc implements WinUser.WindowProc {

@Override
public WinDef.LRESULT callback(WinDef.HWND window, int msg, WinDef.WPARAM wParam, WinDef.LPARAM lParam) {
switch (msg) {
Expand Down Expand Up @@ -167,7 +167,7 @@ private static void calculateWrapper() {
calculate(field);
} catch (Exception e) {
STORAGE.clear();
ExUser32.INSTANCE.SetWindowText(field, "Error!");
ExUser32.INSTANCE.SetWindowText(field, ERROR);
}
}

Expand Down Expand Up @@ -224,7 +224,7 @@ private static void pushOperation(String operation) {
ExUser32.INSTANCE.SetWindowText(field, "");
} else {
STORAGE.clear();
ExUser32.INSTANCE.SetWindowText(field, "Error!");
ExUser32.INSTANCE.SetWindowText(field, ERROR);
}
}

Expand Down Expand Up @@ -262,7 +262,7 @@ private static void pushSymbol(String symbol) {
var buffer = new char[DEFAULT_CAPACITY];
ExUser32.INSTANCE.GetWindowText(field, buffer, DEFAULT_CAPACITY);
var str = Native.toString(buffer);
if ("Error!".equals(str)) {
if (ERROR.equals(str)) {
ExUser32.INSTANCE.SetWindowText(field, symbol);
} else {
ExUser32.INSTANCE.SetWindowText(field, str + symbol);
Expand Down
7 changes: 4 additions & 3 deletions appKotlinJvm/src/main/kotlin/hummel/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ private const val BUTTON_SQUARE_ROOT_ID: Int = 22
private const val BUTTON_UNARY_MINUS_ID: Int = 23

private const val DEFAULT_CAPACITY: Int = 100
private const val ERROR: String = "Error!"

private val storage: MutableList<String> = ArrayList()
private val factorial: Array<Int> = arrayOf(1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600)
Expand Down Expand Up @@ -176,7 +177,7 @@ private class WndProc : WinUser.WindowProc {
calculate(field)
} catch (e: Exception) {
storage.clear()
ExUser32.INSTANCE.SetWindowText(field, "Error!")
ExUser32.INSTANCE.SetWindowText(field, ERROR)
}
}

Expand Down Expand Up @@ -232,7 +233,7 @@ private class WndProc : WinUser.WindowProc {
ExUser32.INSTANCE.SetWindowText(field, "")
} else {
storage.clear()
ExUser32.INSTANCE.SetWindowText(field, "Error!")
ExUser32.INSTANCE.SetWindowText(field, ERROR)
}
}

Expand Down Expand Up @@ -272,7 +273,7 @@ private class WndProc : WinUser.WindowProc {
val buffer = CharArray(DEFAULT_CAPACITY)
ExUser32.INSTANCE.GetWindowText(field, buffer, DEFAULT_CAPACITY)
val str = Native.toString(buffer)
if (str == "Error!") {
if (str == ERROR) {
ExUser32.INSTANCE.SetWindowText(field, symbol)
} else {
ExUser32.INSTANCE.SetWindowText(field, str + symbol)
Expand Down
7 changes: 4 additions & 3 deletions appKotlinNative/src/nativeMain/kotlin/hummel/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ private const val BUTTON_SQUARE_ROOT_ID: Int = 22
private const val BUTTON_UNARY_MINUS_ID: Int = 23

private const val DEFAULT_CAPACITY: Int = 100
private const val ERROR = "Error!"

private val storage: MutableList<String> = ArrayList()
private val factorial: Array<Int> = arrayOf(1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600)
Expand Down Expand Up @@ -170,7 +171,7 @@ private fun calculateWrapper() {
calculate(field)
} catch (e: Exception) {
storage.clear()
SetWindowTextW(field, "Error!")
SetWindowTextW(field, ERROR)
}
}

Expand Down Expand Up @@ -229,7 +230,7 @@ private fun pushOperation(operation: String) {
SetWindowTextW(field, "")
} else {
storage.clear()
SetWindowTextW(field, "Error!")
SetWindowTextW(field, ERROR)
}
}
}
Expand Down Expand Up @@ -274,7 +275,7 @@ private fun pushSymbol(symbol: String) {
val buffer = allocArray<WCHARVar>(DEFAULT_CAPACITY)
GetWindowTextW(field, buffer.reinterpret(), DEFAULT_CAPACITY)
val str = buffer.toKString()
if (str == "Error!") {
if (str == ERROR) {
SetWindowTextW(field, symbol)
} else {
SetWindowTextW(field, str + symbol)
Expand Down

0 comments on commit 7bb8589

Please sign in to comment.