diff --git a/CalculatorController.java b/CalculatorController.java index 70144cf..af4e5da 100644 --- a/CalculatorController.java +++ b/CalculatorController.java @@ -71,9 +71,9 @@ public class CalculatorController { } String firstNumberText = (firstNumber % 1 == 0) ? String.valueOf((int) firstNumber) : String.valueOf(firstNumber); operator = op; - currentInput.setLength(0); // 清空当前输入以便输入下一个数字 isOperationClicked = true; - inputField.setText(firstNumberText + " " + operator); // 显示当前操作 + currentInput.append(operator); + inputField.setText(firstNumberText + " " + operator + " "); // 显示当前操作 } @FXML @@ -140,7 +140,6 @@ public class CalculatorController { if (currentInput.length() > 0) { // 移除最后一个字符 currentInput.deleteCharAt(currentInput.length() - 1); - // 如果最后一个字符是空格且还有字符,继续删除空格(用于清理运算符后面的空格) while (currentInput.length() > 0 && currentInput.charAt(currentInput.length() - 1) == ' ') { currentInput.deleteCharAt(currentInput.length() - 1); diff --git a/out/production/Calculator/CalculatorController.class b/out/production/Calculator/CalculatorController.class index d9d7840..086cf3f 100644 Binary files a/out/production/Calculator/CalculatorController.class and b/out/production/Calculator/CalculatorController.class differ