From 9190cedf0969c28ba4d9316e5bb2e3529cadb8c8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=99=88=E4=BD=B3=E5=AA=9B?= <2487706653@qq.com>
Date: Wed, 9 Oct 2024 23:24:30 +0800
Subject: [PATCH 1/3] =?UTF-8?q?=E9=BE=9A=E5=BF=83=E6=80=A1=E4=BF=AE?=
=?UTF-8?q?=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Calculator.java | 1 -
1 file changed, 1 deletion(-)
diff --git a/Calculator.java b/Calculator.java
index 0fb62b1..cf17971 100644
--- a/Calculator.java
+++ b/Calculator.java
@@ -38,7 +38,6 @@ public class Calculator extends JFrame implements ActionListener {
add(display, BorderLayout.NORTH);
add(panel, BorderLayout.CENTER);
-
setTitle("Calculator");
setSize(400, 500);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
From a9f77c95edbcf23be3d00c4aadcd6d05b64a6f12 Mon Sep 17 00:00:00 2001
From: gxy <2107831483@qq.com>
Date: Wed, 9 Oct 2024 23:35:11 +0800
Subject: [PATCH 2/3] =?UTF-8?q?=E9=BE=9A=E5=BF=83=E6=80=A1=E7=AC=AC?=
=?UTF-8?q?=E4=BA=8C=E6=AC=A1=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.idea/.gitignore | 3 +++
.idea/misc.xml | 6 ++++++
.idea/modules.xml | 8 ++++++++
.idea/vcs.xml | 6 ++++++
Calculator.java | 6 ------
lesson2.iml | 11 +++++++++++
6 files changed, 34 insertions(+), 6 deletions(-)
create mode 100644 .idea/.gitignore
create mode 100644 .idea/misc.xml
create mode 100644 .idea/modules.xml
create mode 100644 .idea/vcs.xml
create mode 100644 lesson2.iml
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..359bb53
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,3 @@
+# 默认忽略的文件
+/shelf/
+/workspace.xml
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..0548357
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..a75e6a5
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Calculator.java b/Calculator.java
index cf17971..03441f0 100644
--- a/Calculator.java
+++ b/Calculator.java
@@ -9,7 +9,6 @@ import javax.script.ScriptException;
public class Calculator extends JFrame implements ActionListener {
private JTextField display;
private StringBuilder input;
-
public Calculator() {
input = new StringBuilder();
display = new JTextField();
@@ -20,14 +19,12 @@ public class Calculator extends JFrame implements ActionListener {
JPanel panel = new JPanel();
panel.setLayout(new GridLayout(4, 4, 10, 10));
panel.setBackground(Color.GRAY);
-
String[] buttons = {
"7", "8", "9", "/",
"4", "5", "6", "*",
"1", "2", "3", "-",
"C", "0", "=", "+"
};
-
for (String text : buttons) {
JButton button = new JButton(text);
button.setFont(new Font("Arial", Font.PLAIN, 24));
@@ -35,7 +32,6 @@ public class Calculator extends JFrame implements ActionListener {
button.setBackground(Color.WHITE);
panel.add(button);
}
-
add(display, BorderLayout.NORTH);
add(panel, BorderLayout.CENTER);
setTitle("Calculator");
@@ -63,12 +59,10 @@ public class Calculator extends JFrame implements ActionListener {
display.setText(input.toString());
}
}
-
private double evaluate(String expression) throws ScriptException {
ScriptEngine engine = new ScriptEngineManager().getEngineByName("JavaScript");
return ((Number) engine.eval(expression)).doubleValue();
}
-//11122222
public static void main(String[] args) {
SwingUtilities.invokeLater(() -> {
Calculator calculator = new Calculator();
diff --git a/lesson2.iml b/lesson2.iml
new file mode 100644
index 0000000..b107a2d
--- /dev/null
+++ b/lesson2.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
From 5a7ea4067331dd29a8735245b374a7eac5ba9f5f Mon Sep 17 00:00:00 2001
From: gxy <2107831483@qq.com>
Date: Wed, 9 Oct 2024 23:36:20 +0800
Subject: [PATCH 3/3] =?UTF-8?q?=E9=BE=9A=E5=BF=83=E6=80=A1=E7=AC=AC?=
=?UTF-8?q?=E4=BA=8C=E6=AC=A1=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Calculator.java | 1 -
1 file changed, 1 deletion(-)
diff --git a/Calculator.java b/Calculator.java
index 03441f0..c121c36 100644
--- a/Calculator.java
+++ b/Calculator.java
@@ -5,7 +5,6 @@ import java.awt.event.ActionListener;
import javax.script.ScriptEngineManager;
import javax.script.ScriptEngine;
import javax.script.ScriptException;
-
public class Calculator extends JFrame implements ActionListener {
private JTextField display;
private StringBuilder input;