From f8852fa3493077a458fdb90eddffcc1056c1397b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=94=90=E7=9D=BF?= <2475574364@qq.com> Date: Mon, 7 Jun 2021 18:21:27 +0800 Subject: [PATCH 01/16] =?UTF-8?q?=E5=88=9B=E5=BB=BA=E4=BA=86=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E7=AA=97=E5=8F=A3=EF=BC=8C=E5=B9=B6=E5=B0=86=E7=AA=97?= =?UTF-8?q?=E5=8F=A3=E6=94=BE=E5=9C=A8=E5=B1=8F=E5=B9=95=E6=AD=A3=E4=B8=AD?= =?UTF-8?q?=E9=97=B4=E3=80=82=20=E5=88=9B=E5=BB=BA=E4=BA=86=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E7=AA=97=E5=8F=A3=EF=BC=8C=E5=B9=B6=E5=B0=86=E7=AA=97?= =?UTF-8?q?=E5=8F=A3=E6=94=BE=E5=9C=A8=E5=B1=8F=E5=B9=95=E6=AD=A3=E4=B8=AD?= =?UTF-8?q?=E9=97=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- java2020spring/Calculator.java | 23 +++++++++++++++++++++++ java2020spring/Const.java | 14 ++++++++++++++ java2020spring/resultText.java | 17 +++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 java2020spring/Calculator.java create mode 100644 java2020spring/Const.java create mode 100644 java2020spring/resultText.java diff --git a/java2020spring/Calculator.java b/java2020spring/Calculator.java new file mode 100644 index 0000000..436812a --- /dev/null +++ b/java2020spring/Calculator.java @@ -0,0 +1,23 @@ +package java2020spring; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +public class Calculator extends JFrame { + + public Calculator() throws HeadlessException { + this.setTitle(Const.TITLE); + this.setSize(Const.FRAME_W,Const.FRAME_H); + this.setLayout(new BorderLayout()); + this.setLocation(Const.FRAME_X,Const.FRAME_Y); + this.setResizable(false); + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + } + + public static void main(String[] args) { + Calculator calculator=new Calculator(); + calculator.setVisible(true); + } +} diff --git a/java2020spring/Const.java b/java2020spring/Const.java new file mode 100644 index 0000000..32cb283 --- /dev/null +++ b/java2020spring/Const.java @@ -0,0 +1,14 @@ +package java2020spring; + +import java.awt.*; + +public class Const { + public static final int FRAME_W=300; + public static final int FRAME_H=300; + public static final int SCREEN_W=Toolkit.getDefaultToolkit().getScreenSize().width; + public static final int SCREEN_H=Toolkit.getDefaultToolkit().getScreenSize().height; + public static final int FRAME_X=(SCREEN_W-FRAME_W)/2; + public static final int FRAME_Y=(SCREEN_H-FRAME_H)/2; + public static final String TITLE="计算器"; + +} diff --git a/java2020spring/resultText.java b/java2020spring/resultText.java new file mode 100644 index 0000000..9a0cb4f --- /dev/null +++ b/java2020spring/resultText.java @@ -0,0 +1,17 @@ +package java2020spring; + +import java.awt.Color; + +public class resultText { + + public static void setHorizontalAlignment(int right) { + // TODO 自动生成的方法存根 + + } + + public static void setBackground(Color white) { + // TODO 自动生成的方法存根 + + } + +} -- Gitee From 30bbf89edb9b088b8f80554a34055fddfd0b64d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=94=90=E7=9D=BF?= <2475574364@qq.com> Date: Tue, 8 Jun 2021 20:53:24 +0800 Subject: [PATCH 02/16] =?UTF-8?q?=E7=AC=AC=E4=BA=8C=E6=AC=A1=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=EF=BC=8C=E6=B7=BB=E5=8A=A0=E4=BA=86=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=B1=8F=E6=96=87=E6=9C=AC=E6=A1=86=E5=92=8C=E5=8E=86=E5=8F=B2?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=96=87=E6=9C=AC=E6=A1=86=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E5=9C=A8=E5=85=B6=E4=B8=AD=E6=B7=BB=E5=8A=A0=E4=BA=86=E4=B8=A4?= =?UTF-8?q?=E4=B8=AA=E5=9E=82=E7=9B=B4=E6=BB=9A=E5=8A=A8=E6=BB=91=E6=9D=A1?= =?UTF-8?q?=E5=92=8C=E4=B8=80=E4=B8=AA=E6=B0=B4=E5=B9=B3=E6=BB=9A=E5=8A=A8?= =?UTF-8?q?=E6=BB=91=E6=9D=A1=EF=BC=8C=E6=9C=80=E5=90=8E=E8=BF=98=E5=B8=83?= =?UTF-8?q?=E7=BD=AE=E4=BA=866=E8=A1=8C5=E5=88=97=E7=9A=84=E7=BD=91?= =?UTF-8?q?=E6=A0=BC=EF=BC=8C=E6=94=BE=E7=BD=AE=E6=8C=89=E9=92=AE=E3=80=82?= =?UTF-8?q?=20=E7=AC=AC=E4=BA=8C=E6=AC=A1=E6=8F=90=E4=BA=A4=EF=BC=8C?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E6=98=BE=E7=A4=BA=E5=B1=8F=E6=96=87?= =?UTF-8?q?=E6=9C=AC=E6=A1=86=E5=92=8C=E5=8E=86=E5=8F=B2=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E6=96=87=E6=9C=AC=E6=A1=86=EF=BC=8C=E5=B9=B6=E5=9C=A8=E5=85=B6?= =?UTF-8?q?=E4=B8=AD=E6=B7=BB=E5=8A=A0=E4=BA=86=E4=B8=A4=E4=B8=AA=E5=9E=82?= =?UTF-8?q?=E7=9B=B4=E6=BB=9A=E5=8A=A8=E6=BB=91=E6=9D=A1=E5=92=8C=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E6=B0=B4=E5=B9=B3=E6=BB=9A=E5=8A=A8=E6=BB=91=E6=9D=A1?= =?UTF-8?q?=EF=BC=8C=E6=9C=80=E5=90=8E=E8=BF=98=E5=B8=83=E7=BD=AE=E4=BA=86?= =?UTF-8?q?6=E8=A1=8C5=E5=88=97=E7=9A=84=E7=BD=91=E6=A0=BC=EF=BC=8C?= =?UTF-8?q?=E6=94=BE=E7=BD=AE=E6=8C=89=E9=92=AE=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Calculator.java | 175 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100644 Calculator.java diff --git a/Calculator.java b/Calculator.java new file mode 100644 index 0000000..906dde1 --- /dev/null +++ b/Calculator.java @@ -0,0 +1,175 @@ +package java2020spring; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.lang.reflect.Array; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.GridLayout; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; + +public class Calculator extends JFrame implements ActionListener{ + private static final long serialVersionUID = 1L; + private static final String COMMANDS = null; + private static final Icon[] COMMAND = null; + private static final String M = null; + + public static void main(String[] args) { + Calculator calculator=new Calculator(); + calculator.setVisible(true); + } + + public Calculator() throws HeadlessException { + super("Caculator"); + resultText.setAlignmentX(RIGHT_ALIGNMENT); + this.setTitle(Const.TITLE); + this.setSize(Const.FRAME_W,Const.FRAME_H); + this.setLayout(new BorderLayout()); + this.setLocation(Const.FRAME_X,Const.FRAME_Y); + this.setResizable(false); + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + resultText.setBounds(20,18,255,115); + resultText.setAlignmentX(RIGHT_ALIGNMENT); + resultText.setEditable(false); + History.setBounds(290,40,250,370); + History.setAlignmentX(LEFT_ALIGNMENT); + History.setEditable(false); + label.setBounds(400,15,100,20); + j1.setBounds(20,18,320,115); + j1.setLayout(new GridLayout()); + j2.setBounds(380,40,250,380); + j2.setLayout(new GridLayout()); + resultText.setLineWrap(true); + resultText.setWrapStyleWord(true); + History.setLineWrap(true); + History.setWrapStyleWord(true); + g1.setViewportView(resultText); + g1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + g2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + g2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + g2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + j1.add(g1); + j2.add(g2); + this.add(j1); + this.add(j2); + this.setLayout(null); + this.add(label); + int x=20,y=150; + for (int i=0;i Date: Tue, 8 Jun 2021 20:56:39 +0800 Subject: [PATCH 03/16] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20Ca?= =?UTF-8?q?lculator.java?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Calculator.java | 175 ------------------------------------------------ 1 file changed, 175 deletions(-) delete mode 100644 Calculator.java diff --git a/Calculator.java b/Calculator.java deleted file mode 100644 index 906dde1..0000000 --- a/Calculator.java +++ /dev/null @@ -1,175 +0,0 @@ -package java2020spring; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.lang.reflect.Array; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.GridLayout; -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.JPanel; - -public class Calculator extends JFrame implements ActionListener{ - private static final long serialVersionUID = 1L; - private static final String COMMANDS = null; - private static final Icon[] COMMAND = null; - private static final String M = null; - - public static void main(String[] args) { - Calculator calculator=new Calculator(); - calculator.setVisible(true); - } - - public Calculator() throws HeadlessException { - super("Caculator"); - resultText.setAlignmentX(RIGHT_ALIGNMENT); - this.setTitle(Const.TITLE); - this.setSize(Const.FRAME_W,Const.FRAME_H); - this.setLayout(new BorderLayout()); - this.setLocation(Const.FRAME_X,Const.FRAME_Y); - this.setResizable(false); - this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - resultText.setBounds(20,18,255,115); - resultText.setAlignmentX(RIGHT_ALIGNMENT); - resultText.setEditable(false); - History.setBounds(290,40,250,370); - History.setAlignmentX(LEFT_ALIGNMENT); - History.setEditable(false); - label.setBounds(400,15,100,20); - j1.setBounds(20,18,320,115); - j1.setLayout(new GridLayout()); - j2.setBounds(380,40,250,380); - j2.setLayout(new GridLayout()); - resultText.setLineWrap(true); - resultText.setWrapStyleWord(true); - History.setLineWrap(true); - History.setWrapStyleWord(true); - g1.setViewportView(resultText); - g1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); - g2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); - g2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); - g2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); - j1.add(g1); - j2.add(g2); - this.add(j1); - this.add(j2); - this.setLayout(null); - this.add(label); - int x=20,y=150; - for (int i=0;i Date: Tue, 8 Jun 2021 21:02:27 +0800 Subject: [PATCH 04/16] =?UTF-8?q?=E7=AC=AC=E4=BA=8C=E6=AC=A1=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=EF=BC=8C=E6=B7=BB=E5=8A=A0=E4=BA=86=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=B1=8F=E6=96=87=E6=9C=AC=E6=A1=86=E5=92=8C=E5=8E=86=E5=8F=B2?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E6=96=87=E6=9C=AC=E6=A1=86=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E5=9C=A8=E5=85=B6=E4=B8=AD=E6=B7=BB=E5=8A=A0=E4=BA=86=E4=B8=A4?= =?UTF-8?q?=E4=B8=AA=E5=9E=82=E7=9B=B4=E6=BB=9A=E5=8A=A8=E6=BB=91=E6=9D=A1?= =?UTF-8?q?=E5=92=8C=E4=B8=80=E4=B8=AA=E6=B0=B4=E5=B9=B3=E6=BB=9A=E5=8A=A8?= =?UTF-8?q?=E6=BB=91=E6=9D=A1=EF=BC=8C=E6=9C=80=E5=90=8E=E8=BF=98=E5=B8=83?= =?UTF-8?q?=E7=BD=AE=E4=BA=866=E8=A1=8C5=E5=88=97=E7=9A=84=E7=BD=91?= =?UTF-8?q?=E6=A0=BC=EF=BC=8C=E6=94=BE=E7=BD=AE=E6=8C=89=E9=92=AE=E3=80=82?= =?UTF-8?q?=20=E7=AC=AC=E4=BA=8C=E6=AC=A1=E6=8F=90=E4=BA=A4=EF=BC=8C?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E6=98=BE=E7=A4=BA=E5=B1=8F=E6=96=87?= =?UTF-8?q?=E6=9C=AC=E6=A1=86=E5=92=8C=E5=8E=86=E5=8F=B2=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E6=96=87=E6=9C=AC=E6=A1=86=EF=BC=8C=E5=B9=B6=E5=9C=A8=E5=85=B6?= =?UTF-8?q?=E4=B8=AD=E6=B7=BB=E5=8A=A0=E4=BA=86=E4=B8=A4=E4=B8=AA=E5=9E=82?= =?UTF-8?q?=E7=9B=B4=E6=BB=9A=E5=8A=A8=E6=BB=91=E6=9D=A1=E5=92=8C=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E6=B0=B4=E5=B9=B3=E6=BB=9A=E5=8A=A8=E6=BB=91=E6=9D=A1?= =?UTF-8?q?=EF=BC=8C=E6=9C=80=E5=90=8E=E8=BF=98=E5=B8=83=E7=BD=AE=E4=BA=86?= =?UTF-8?q?6=E8=A1=8C5=E5=88=97=E7=9A=84=E7=BD=91=E6=A0=BC=EF=BC=8C?= =?UTF-8?q?=E6=94=BE=E7=BD=AE=E6=8C=89=E9=92=AE=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Calculator.java | 136 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 Calculator.java diff --git a/Calculator.java b/Calculator.java new file mode 100644 index 0000000..b9d2fc2 --- /dev/null +++ b/Calculator.java @@ -0,0 +1,136 @@ +package java2020spring; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.lang.reflect.Array; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.GridLayout; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; + +public class Calculator extends JFrame implements ActionListener{ + private static final long serialVersionUID = 1L; + private static final String COMMANDS = null; + private static final Icon[] COMMAND = null; + private static final String M = null; + + public static void main(String[] args) { + Calculator calculator=new Calculator(); + calculator.setVisible(true); + } + + public Calculator() throws HeadlessException { + super("Caculator"); + resultText.setAlignmentX(RIGHT_ALIGNMENT); + this.setTitle(Const.TITLE); + this.setSize(Const.FRAME_W,Const.FRAME_H); + this.setLayout(new BorderLayout()); + this.setLocation(Const.FRAME_X,Const.FRAME_Y); + this.setResizable(false); + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + resultText.setBounds(20,18,255,115); + resultText.setAlignmentX(RIGHT_ALIGNMENT); + resultText.setEditable(false); + History.setBounds(290,40,250,370); + History.setAlignmentX(LEFT_ALIGNMENT); + History.setEditable(false); + label.setBounds(400,15,100,20); + j1.setBounds(20,18,320,115); + j1.setLayout(new GridLayout()); + j2.setBounds(380,40,250,380); + j2.setLayout(new GridLayout()); + resultText.setLineWrap(true); + resultText.setWrapStyleWord(true); + History.setLineWrap(true); + History.setWrapStyleWord(true); + g1.setViewportView(resultText); + g1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + g2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + g2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + g2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + j1.add(g1); + j2.add(g2); + this.add(j1); + this.add(j2); + this.setLayout(null); + this.add(label); + int x=20,y=150; + for (int i=0;i Date: Tue, 8 Jun 2021 23:19:06 +0800 Subject: [PATCH 05/16] =?UTF-8?q?add=20=E8=AE=A1=E7=AE=97=E5=99=A8?= =?UTF-8?q?=E7=AC=AC=E4=B8=89=E6=AC=A1=E6=8F=90=E4=BA=A4.=20=E7=AC=AC?= =?UTF-8?q?=E4=B8=89=E6=AC=A1=EF=BC=8C=E8=BF=9B=E8=A1=8C=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E7=9A=84=E5=A4=84=E7=90=86=E3=80=82=E5=B0=86=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E7=9A=84=E6=8C=89=E9=92=AE=E7=9A=84=E6=93=8D=E4=BD=9C=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=88=B0=E6=98=BE=E7=A4=BA=E5=B1=8F=E6=96=87=E6=9C=AC?= =?UTF-8?q?=E6=A1=86=E4=B8=AD=EF=BC=8C=E5=B9=B6=E4=BD=BF=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E7=9A=84=E6=95=B0=E6=8D=AE=E8=AE=B0=E5=BD=95=E5=88=B0=E5=8E=86?= =?UTF-8?q?=E5=8F=B2=E8=AE=B0=E5=BD=95=E6=96=87=E6=9C=AC=E6=A1=86=E4=B8=AD?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...0\211\346\254\241\346\217\220\344\272\244" | 204 ++++++++++++++++++ 1 file changed, 204 insertions(+) create mode 100644 "\350\256\241\347\256\227\345\231\250\347\254\254\344\270\211\346\254\241\346\217\220\344\272\244" diff --git "a/\350\256\241\347\256\227\345\231\250\347\254\254\344\270\211\346\254\241\346\217\220\344\272\244" "b/\350\256\241\347\256\227\345\231\250\347\254\254\344\270\211\346\254\241\346\217\220\344\272\244" new file mode 100644 index 0000000..5ae4308 --- /dev/null +++ "b/\350\256\241\347\256\227\345\231\250\347\254\254\344\270\211\346\254\241\346\217\220\344\272\244" @@ -0,0 +1,204 @@ +package java2020spring; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.lang.reflect.Array; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.GridLayout; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; + +public class Calculator extends JFrame implements ActionListener{ + private static final long serialVersionUID = 1L; + private static final String COMMANDS = null; + private static final Icon[] COMMAND = null; + private static final String M = null; + + public static void main(String[] args) { + Calculator calculator=new Calculator(); + calculator.setVisible(true); + } + + public Calculator() throws HeadlessException { + super("Caculator"); + resultText.setAlignmentX(RIGHT_ALIGNMENT); + this.setTitle(Const.TITLE); + this.setSize(Const.FRAME_W,Const.FRAME_H); + this.setLayout(new BorderLayout()); + this.setLocation(Const.FRAME_X,Const.FRAME_Y); + this.setResizable(false); + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + resultText.setBounds(20,18,255,115); + resultText.setAlignmentX(RIGHT_ALIGNMENT); + resultText.setEditable(false); + History.setBounds(290,40,250,370); + History.setAlignmentX(LEFT_ALIGNMENT); + History.setEditable(false); + label.setBounds(400,15,100,20); + j1.setBounds(20,18,320,115); + j1.setLayout(new GridLayout()); + j2.setBounds(380,40,250,380); + j2.setLayout(new GridLayout()); + resultText.setLineWrap(true); + resultText.setWrapStyleWord(true); + History.setLineWrap(true); + History.setWrapStyleWord(true); + g1.setViewportView(resultText); + g1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + g2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + g2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + g2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + j1.add(g1); + j2.add(g2); + this.add(j1); + this.add(j2); + this.setLayout(null); + this.add(label); + int x=20,y=150; + for (int i=0;i Date: Tue, 8 Jun 2021 23:19:42 +0800 Subject: [PATCH 06/16] =?UTF-8?q?=E9=87=8D=E5=91=BD=E5=90=8D=20java2020spr?= =?UTF-8?q?ing=20=E4=B8=BA=20=E8=AE=A1=E7=AE=97=E5=99=A8=E7=AC=AC=E4=B8=80?= =?UTF-8?q?=E6=AC=A1=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Calculator.java" | 0 .../Const.java" | 0 .../resultText.java" | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename java2020spring/Calculator.java => "\350\256\241\347\256\227\345\231\250\347\254\254\344\270\200\346\254\241\346\217\220\344\272\244/Calculator.java" (100%) rename java2020spring/Const.java => "\350\256\241\347\256\227\345\231\250\347\254\254\344\270\200\346\254\241\346\217\220\344\272\244/Const.java" (100%) rename java2020spring/resultText.java => "\350\256\241\347\256\227\345\231\250\347\254\254\344\270\200\346\254\241\346\217\220\344\272\244/resultText.java" (100%) diff --git a/java2020spring/Calculator.java "b/\350\256\241\347\256\227\345\231\250\347\254\254\344\270\200\346\254\241\346\217\220\344\272\244/Calculator.java" similarity index 100% rename from java2020spring/Calculator.java rename to "\350\256\241\347\256\227\345\231\250\347\254\254\344\270\200\346\254\241\346\217\220\344\272\244/Calculator.java" diff --git a/java2020spring/Const.java "b/\350\256\241\347\256\227\345\231\250\347\254\254\344\270\200\346\254\241\346\217\220\344\272\244/Const.java" similarity index 100% rename from java2020spring/Const.java rename to "\350\256\241\347\256\227\345\231\250\347\254\254\344\270\200\346\254\241\346\217\220\344\272\244/Const.java" diff --git a/java2020spring/resultText.java "b/\350\256\241\347\256\227\345\231\250\347\254\254\344\270\200\346\254\241\346\217\220\344\272\244/resultText.java" similarity index 100% rename from java2020spring/resultText.java rename to "\350\256\241\347\256\227\345\231\250\347\254\254\344\270\200\346\254\241\346\217\220\344\272\244/resultText.java" -- Gitee From f8a00a1563467633df28161a7d28dc13129c18ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=94=90=E7=9D=BF?= <2475574364@qq.com> Date: Wed, 9 Jun 2021 22:26:08 +0800 Subject: [PATCH 07/16] =?UTF-8?q?add=20=E8=AE=A1=E7=AE=97=E6=9C=BA?= =?UTF-8?q?=E7=AC=AC=E5=9B=9B=E6=AC=A1=E6=8F=90=E4=BA=A4.=20=E7=AC=AC?= =?UTF-8?q?=E5=9B=9B=E6=AC=A1=E6=8F=90=E4=BA=A4=EF=BC=8C=E5=B0=86=E4=B8=AD?= =?UTF-8?q?=E7=BC=80=E8=A1=A8=E8=BE=BE=E5=BC=8F=E8=BD=AC=E6=8D=A2=E4=B8=BA?= =?UTF-8?q?=E5=90=8E=E7=BC=80=E8=A1=A8=E8=BE=BE=E5=BC=8F=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E4=BA=86=E5=8A=A0=E5=87=8F=E4=B9=98=E9=99=A4?= =?UTF-8?q?=E5=9B=9B=E4=B8=AA=E8=BF=90=E7=AE=97=E6=93=8D=E4=BD=9C=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...3\233\346\254\241\346\217\220\344\272\244" | 394 ++++++++++++++++++ 1 file changed, 394 insertions(+) create mode 100644 "\350\256\241\347\256\227\346\234\272\347\254\254\345\233\233\346\254\241\346\217\220\344\272\244" diff --git "a/\350\256\241\347\256\227\346\234\272\347\254\254\345\233\233\346\254\241\346\217\220\344\272\244" "b/\350\256\241\347\256\227\346\234\272\347\254\254\345\233\233\346\254\241\346\217\220\344\272\244" new file mode 100644 index 0000000..5711886 --- /dev/null +++ "b/\350\256\241\347\256\227\346\234\272\347\254\254\345\233\233\346\254\241\346\217\220\344\272\244" @@ -0,0 +1,394 @@ +package calculator; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.lang.reflect.Array; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.GridLayout; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; + +import java2020spring.Const; + +public class Calculator extends JFrame implements ActionListener{ + private static final long serialVersionUID = 1L; + private static final String COMMANDS = null; + private static final Icon[] COMMAND = null; + private static final String M = null; + + public static void main(String[] args) { + Calculator calculator=new Calculator(); + calculator.setVisible(true); + } + + public Calculator() throws HeadlessException { + super("Caculator"); + resultText.setAlignmentX(RIGHT_ALIGNMENT); + this.setTitle(Const.TITLE); + this.setSize(Const.FRAME_W,Const.FRAME_H); + this.setLayout(new BorderLayout()); + this.setLocation(Const.FRAME_X,Const.FRAME_Y); + this.setResizable(false); + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + resultText.setBounds(20,18,255,115); + resultText.setAlignmentX(RIGHT_ALIGNMENT); + resultText.setEditable(false); + History.setBounds(290,40,250,370); + History.setAlignmentX(LEFT_ALIGNMENT); + History.setEditable(false); + label.setBounds(400,15,100,20); + j1.setBounds(20,18,320,115); + j1.setLayout(new GridLayout()); + j2.setBounds(380,40,250,380); + j2.setLayout(new GridLayout()); + resultText.setLineWrap(true); + resultText.setWrapStyleWord(true); + History.setLineWrap(true); + History.setWrapStyleWord(true); + g1.setViewportView(resultText); + g1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + g2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + g2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + g2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + j1.add(g1); + j2.add(g2); + this.add(j1); + this.add(j2); + this.setLayout(null); + this.add(label); + int x=20,y=150; + for (int i=0;i=0) + { + c =""; + for(;i=0;i++) + { + c=c+str.charAt(i); + } + i--; + postQueue[f]=c; + f++; + } else if("(".indexOf(str.charAt(i))>=0) + { + d++; + opStack[d]=str.charAt(i); + } + else if(")".indexOf(str.charAt(i))>=0) + { + for(;;) + { + if(opStack[d]!='(') + { + postQueue[f]=opStack[d]+""; + f++; + d--; + } + else + { + d--; + break; + } + } + } + if("*%/".indexOf(str.charAt(i))>=0) + { + if(d==-1) + { + d++; + opStack[d]=str.charAt(i); + } else { + if ("*%/".indexOf(opStack[d])>=0) + { + postQueue[f]=opStack[d]+""; + f++; + opStack[d]=str.charAt(i); + } + else if("(".indexOf(opStack[d])>=0) + { + d++; + opStack[d]=str.charAt(i); + } + else if("+-".indexOf(str.charAt(i))>=0) { + postQueue[f]=opStack[d] + ""; + f++; + opStack[d]=str.charAt(i); + } + } + } + else if("+-".indexOf(str.charAt(i))>=0) + { + if(d==-1) + { + d++; + opStack[d]=str.charAt(i); + } + else { + if("*%/".indexOf(opStack[d])>=0) + { + postQueue[f]=opStack[d]+""; + f++; + opStack[d]=str.charAt(i); + } + else if("(".indexOf(opStack[d])>=0) + { + d++; + opStack[d]=str.charAt(i); + } + else if("+-".indexOf(str.charAt(i))>=0) + { + postQueue[f]=opStack[d]+""; + f++; + opStack[d]= str.charAt(i); + } + } + } + } + for(;d!=-1;) + { + postQueue[f]=opStack[d]+""; + f++; + d--; + } + return postQueue; + } + + public String Result(String str[]) { + String Result[]=new String[100]; + int Top=-1; + for (int i=0;str[i]!=null;i++) + { + if ("+-*%/".indexOf(str[i])<0) + { + Top++; + Result[Top]=str[i]; + } + if ("+-*%/".indexOf(str[i])>=0) + { + double x,y,n; + x=Double.parseDouble(Result[Top]); + Top--; + y=Double.parseDouble(Result[Top]); + Top--; + if ("-".indexOf(str[i])>=0) { + n=y-x; + Top++; + Result[Top]=String.valueOf(n); + } + if ("+".indexOf(str[i])>=0) { + n=y+x; + Top++; + Result[Top]=String.valueOf(n); + } + if ("*".indexOf(str[i])>=0) { + n=y*x; + Top++; + Result[Top]=String.valueOf(n); + + } + if ("/".indexOf(str[i])>=0) + { + if (x==0) + { + String s="error!"; + return s; + } + else { + n=y/x; + Top++; + Result[Top]=String.valueOf(n); + } + } + if("%".indexOf(str[i])>=0) + { + if (x==0) + { + String s="error!"; + return s; + } + else { + n=y%x; + Top++; + Result[Top]=String.valueOf(n); + } + } + + } + } + return Result[Top]; + } + + private String p(String a2) { + // TODO 鑷姩鐢熸垚鐨勬柟娉曞瓨鏍 + return null; + } + + private String k(String a2) { + // TODO 鑷姩鐢熸垚鐨勬柟娉曞瓨鏍 + return null; + } + + public static String getCommands() { + return COMMANDS; + } + + public static Icon[] getCommand() { + return COMMAND; + } + + public static String getM() { + return M; + } + + public JButton[] getCommands2() { + return commands2; + } + + public void setCommands2(JButton[] commands2) { + this.commands2 = commands2; + } + + public Array[] getMs() { + return ms; + } + + public void setMs(Array[] ms) { + this.ms = ms; + } + + public JButton[] getMs2() { + return ms2; + } + + public void setMs2(JButton[] ms2) { + this.ms2 = ms2; + } +} -- Gitee From 15204943792dd104d47ec7a7890255c88d922806 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=94=90=E7=9D=BF?= <2475574364@qq.com> Date: Wed, 9 Jun 2021 22:32:42 +0800 Subject: [PATCH 08/16] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E6=9C=BA=E7=AC=AC=E5=9B=9B=E6=AC=A1=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...3\233\346\254\241\346\217\220\344\272\244" | 394 ------------------ 1 file changed, 394 deletions(-) delete mode 100644 "\350\256\241\347\256\227\346\234\272\347\254\254\345\233\233\346\254\241\346\217\220\344\272\244" diff --git "a/\350\256\241\347\256\227\346\234\272\347\254\254\345\233\233\346\254\241\346\217\220\344\272\244" "b/\350\256\241\347\256\227\346\234\272\347\254\254\345\233\233\346\254\241\346\217\220\344\272\244" deleted file mode 100644 index 5711886..0000000 --- "a/\350\256\241\347\256\227\346\234\272\347\254\254\345\233\233\346\254\241\346\217\220\344\272\244" +++ /dev/null @@ -1,394 +0,0 @@ -package calculator; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.lang.reflect.Array; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.GridLayout; -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.JPanel; - -import java2020spring.Const; - -public class Calculator extends JFrame implements ActionListener{ - private static final long serialVersionUID = 1L; - private static final String COMMANDS = null; - private static final Icon[] COMMAND = null; - private static final String M = null; - - public static void main(String[] args) { - Calculator calculator=new Calculator(); - calculator.setVisible(true); - } - - public Calculator() throws HeadlessException { - super("Caculator"); - resultText.setAlignmentX(RIGHT_ALIGNMENT); - this.setTitle(Const.TITLE); - this.setSize(Const.FRAME_W,Const.FRAME_H); - this.setLayout(new BorderLayout()); - this.setLocation(Const.FRAME_X,Const.FRAME_Y); - this.setResizable(false); - this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - resultText.setBounds(20,18,255,115); - resultText.setAlignmentX(RIGHT_ALIGNMENT); - resultText.setEditable(false); - History.setBounds(290,40,250,370); - History.setAlignmentX(LEFT_ALIGNMENT); - History.setEditable(false); - label.setBounds(400,15,100,20); - j1.setBounds(20,18,320,115); - j1.setLayout(new GridLayout()); - j2.setBounds(380,40,250,380); - j2.setLayout(new GridLayout()); - resultText.setLineWrap(true); - resultText.setWrapStyleWord(true); - History.setLineWrap(true); - History.setWrapStyleWord(true); - g1.setViewportView(resultText); - g1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); - g2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); - g2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); - g2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); - j1.add(g1); - j2.add(g2); - this.add(j1); - this.add(j2); - this.setLayout(null); - this.add(label); - int x=20,y=150; - for (int i=0;i=0) - { - c =""; - for(;i=0;i++) - { - c=c+str.charAt(i); - } - i--; - postQueue[f]=c; - f++; - } else if("(".indexOf(str.charAt(i))>=0) - { - d++; - opStack[d]=str.charAt(i); - } - else if(")".indexOf(str.charAt(i))>=0) - { - for(;;) - { - if(opStack[d]!='(') - { - postQueue[f]=opStack[d]+""; - f++; - d--; - } - else - { - d--; - break; - } - } - } - if("*%/".indexOf(str.charAt(i))>=0) - { - if(d==-1) - { - d++; - opStack[d]=str.charAt(i); - } else { - if ("*%/".indexOf(opStack[d])>=0) - { - postQueue[f]=opStack[d]+""; - f++; - opStack[d]=str.charAt(i); - } - else if("(".indexOf(opStack[d])>=0) - { - d++; - opStack[d]=str.charAt(i); - } - else if("+-".indexOf(str.charAt(i))>=0) { - postQueue[f]=opStack[d] + ""; - f++; - opStack[d]=str.charAt(i); - } - } - } - else if("+-".indexOf(str.charAt(i))>=0) - { - if(d==-1) - { - d++; - opStack[d]=str.charAt(i); - } - else { - if("*%/".indexOf(opStack[d])>=0) - { - postQueue[f]=opStack[d]+""; - f++; - opStack[d]=str.charAt(i); - } - else if("(".indexOf(opStack[d])>=0) - { - d++; - opStack[d]=str.charAt(i); - } - else if("+-".indexOf(str.charAt(i))>=0) - { - postQueue[f]=opStack[d]+""; - f++; - opStack[d]= str.charAt(i); - } - } - } - } - for(;d!=-1;) - { - postQueue[f]=opStack[d]+""; - f++; - d--; - } - return postQueue; - } - - public String Result(String str[]) { - String Result[]=new String[100]; - int Top=-1; - for (int i=0;str[i]!=null;i++) - { - if ("+-*%/".indexOf(str[i])<0) - { - Top++; - Result[Top]=str[i]; - } - if ("+-*%/".indexOf(str[i])>=0) - { - double x,y,n; - x=Double.parseDouble(Result[Top]); - Top--; - y=Double.parseDouble(Result[Top]); - Top--; - if ("-".indexOf(str[i])>=0) { - n=y-x; - Top++; - Result[Top]=String.valueOf(n); - } - if ("+".indexOf(str[i])>=0) { - n=y+x; - Top++; - Result[Top]=String.valueOf(n); - } - if ("*".indexOf(str[i])>=0) { - n=y*x; - Top++; - Result[Top]=String.valueOf(n); - - } - if ("/".indexOf(str[i])>=0) - { - if (x==0) - { - String s="error!"; - return s; - } - else { - n=y/x; - Top++; - Result[Top]=String.valueOf(n); - } - } - if("%".indexOf(str[i])>=0) - { - if (x==0) - { - String s="error!"; - return s; - } - else { - n=y%x; - Top++; - Result[Top]=String.valueOf(n); - } - } - - } - } - return Result[Top]; - } - - private String p(String a2) { - // TODO 鑷姩鐢熸垚鐨勬柟娉曞瓨鏍 - return null; - } - - private String k(String a2) { - // TODO 鑷姩鐢熸垚鐨勬柟娉曞瓨鏍 - return null; - } - - public static String getCommands() { - return COMMANDS; - } - - public static Icon[] getCommand() { - return COMMAND; - } - - public static String getM() { - return M; - } - - public JButton[] getCommands2() { - return commands2; - } - - public void setCommands2(JButton[] commands2) { - this.commands2 = commands2; - } - - public Array[] getMs() { - return ms; - } - - public void setMs(Array[] ms) { - this.ms = ms; - } - - public JButton[] getMs2() { - return ms2; - } - - public void setMs2(JButton[] ms2) { - this.ms2 = ms2; - } -} -- Gitee From 2a5c31c4bb764d326153002ad114e6e896ea3154 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=94=90=E7=9D=BF?= <2475574364@qq.com> Date: Wed, 9 Jun 2021 22:42:26 +0800 Subject: [PATCH 09/16] =?UTF-8?q?add=20=E8=AE=A1=E7=AE=97=E5=99=A8?= =?UTF-8?q?=E7=AC=AC=E5=9B=9B=E6=AC=A1=E6=8F=90=E4=BA=A4.=20=E7=AC=AC?= =?UTF-8?q?=E5=9B=9B=E6=AC=A1=E6=8F=90=E4=BA=A4=EF=BC=8C=E5=B0=86=E4=B8=AD?= =?UTF-8?q?=E7=BC=80=E8=A1=A8=E8=BE=BE=E5=BC=8F=E8=BD=AC=E6=8D=A2=E6=88=90?= =?UTF-8?q?=E5=90=8E=E7=BC=80=E8=A1=A8=E8=BE=BE=E5=BC=8F=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E4=BA=86=E5=8A=A0=E5=87=8F=E4=B9=98=E9=99=A4?= =?UTF-8?q?=E8=BF=90=E7=AE=97=E7=9A=84=E6=93=8D=E4=BD=9C=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...3\233\346\254\241\346\217\220\344\272\244" | 400 ++++++++++++++++++ 1 file changed, 400 insertions(+) create mode 100644 "\350\256\241\347\256\227\345\231\250\347\254\254\345\233\233\346\254\241\346\217\220\344\272\244" diff --git "a/\350\256\241\347\256\227\345\231\250\347\254\254\345\233\233\346\254\241\346\217\220\344\272\244" "b/\350\256\241\347\256\227\345\231\250\347\254\254\345\233\233\346\254\241\346\217\220\344\272\244" new file mode 100644 index 0000000..f41a4ac --- /dev/null +++ "b/\350\256\241\347\256\227\345\231\250\347\254\254\345\233\233\346\254\241\346\217\220\344\272\244" @@ -0,0 +1,400 @@ +package calculator; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.lang.reflect.Array; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.GridLayout; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; + +import java2020spring.Const; + +public class Calculator extends JFrame implements ActionListener{ + private static final long serialVersionUID = 1L; + private static final String COMMANDS = null; + private static final Icon[] COMMAND = null; + private static final String M = null; + + public static void main(String[] args) { + Calculator calculator=new Calculator(); + calculator.setVisible(true); + } + + public Calculator() throws HeadlessException { + super("Caculator"); + resultText.setAlignmentX(RIGHT_ALIGNMENT); + this.setTitle(Const.TITLE); + this.setSize(Const.FRAME_W,Const.FRAME_H); + this.setLayout(new BorderLayout()); + this.setLocation(Const.FRAME_X,Const.FRAME_Y); + this.setResizable(false); + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + resultText.setBounds(20,18,255,115); + resultText.setAlignmentX(RIGHT_ALIGNMENT); + resultText.setEditable(false); + History.setBounds(290,40,250,370); + History.setAlignmentX(LEFT_ALIGNMENT); + History.setEditable(false); + label.setBounds(400,15,100,20); + j1.setBounds(20,18,320,115); + j1.setLayout(new GridLayout()); + j2.setBounds(380,40,250,380); + j2.setLayout(new GridLayout()); + resultText.setLineWrap(true); + resultText.setWrapStyleWord(true); + History.setLineWrap(true); + History.setWrapStyleWord(true); + g1.setViewportView(resultText); + g1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + g2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + g2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + g2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + j1.add(g1); + j2.add(g2); + this.add(j1); + this.add(j2); + this.setLayout(null); + this.add(label); + int x=20,y=150; + for (int i=0;i=0) + { + c =""; + for(;i=0;i++) + { + c=c+str.charAt(i); + } + i--; + postQueue[f]=c; + f++; + } else if("(".indexOf(str.charAt(i))>=0) + { + d++; + opStack[d]=str.charAt(i); + } + else if(")".indexOf(str.charAt(i))>=0) + { + for(;;) + { + if(opStack[d]!='(') + { + postQueue[f]=opStack[d]+""; + f++; + d--; + } + else + { + d--; + break; + } + } + } + if("*%/".indexOf(str.charAt(i))>=0) + { + if(d==-1) + { + d++; + opStack[d]=str.charAt(i); + } else { + if ("*%/".indexOf(opStack[d])>=0) + { + postQueue[f]=opStack[d]+""; + f++; + opStack[d]=str.charAt(i); + } + else if("(".indexOf(opStack[d])>=0) + { + d++; + opStack[d]=str.charAt(i); + } + else if("+-".indexOf(str.charAt(i))>=0) { + postQueue[f]=opStack[d] + ""; + f++; + opStack[d]=str.charAt(i); + } + } + } + else if("+-".indexOf(str.charAt(i))>=0) + { + if(d==-1) + { + d++; + opStack[d]=str.charAt(i); + } + else { + if("*%/".indexOf(opStack[d])>=0) + { + postQueue[f]=opStack[d]+""; + f++; + opStack[d]=str.charAt(i); + } + else if("(".indexOf(opStack[d])>=0) + { + d++; + opStack[d]=str.charAt(i); + } + else if("+-".indexOf(str.charAt(i))>=0) + { + postQueue[f]=opStack[d]+""; + f++; + opStack[d]= str.charAt(i); + } + } + } + } + for(;d!=-1;) + { + postQueue[f]=opStack[d]+""; + f++; + d--; + } + return postQueue; + } + + public String Result(String str[]) { + String Result[]=new String[100]; + int Top=-1; + for (int i=0;str[i]!=null;i++) + { + if ("+-*%/".indexOf(str[i])<0) + { + Top++; + Result[Top]=str[i]; + } + if ("+-*%/".indexOf(str[i])>=0) + { + double x,y,n; + x=Double.parseDouble(Result[Top]); + Top--; + y=Double.parseDouble(Result[Top]); + Top--; + if ("-".indexOf(str[i])>=0) { + n=y-x; + Top++; + Result[Top]=String.valueOf(n); + } + if ("+".indexOf(str[i])>=0) { + n=y+x; + Top++; + Result[Top]=String.valueOf(n); + } + if ("*".indexOf(str[i])>=0) { + n=y*x; + Top++; + Result[Top]=String.valueOf(n); + + } + if ("/".indexOf(str[i])>=0) + { + if (x==0) + { + String s="error!"; + return s; + } + else { + n=y/x; + Top++; + Result[Top]=String.valueOf(n); + } + } + if("%".indexOf(str[i])>=0) + { + if (x==0) + { + String s="error!"; + return s; + } + else { + n=y%x; + Top++; + Result[Top]=String.valueOf(n); + } + } + + } + } + return Result[Top]; + } + + + + private String p(String a2) { + // TODO 鑷姩鐢熸垚鐨勬柟娉曞瓨鏍 + return null; + } + + private String k(String a2) { + // TODO 鑷姩鐢熸垚鐨勬柟娉曞瓨鏍 + return null; + } + + public static String getCommands() { + return COMMANDS; + } + + public static Icon[] getCommand() { + return COMMAND; + } + + public static String getM() { + return M; + } + + public JButton[] getCommands2() { + return commands2; + } + + public void setCommands2(JButton[] commands2) { + this.commands2 = commands2; + } + + public Array[] getMs() { + return ms; + } + + public void setMs(Array[] ms) { + this.ms = ms; + } + + public JButton[] getMs2() { + return ms2; + } + + public void setMs2(JButton[] ms2) { + this.ms2 = ms2; + } +} + + + + -- Gitee From e9ea2d0f658faac1dd58f1aa2fa502127df29451 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=94=90=E7=9D=BF?= <2475574364@qq.com> Date: Thu, 10 Jun 2021 04:17:49 +0800 Subject: [PATCH 10/16] =?UTF-8?q?add=20C:\Users\admin\git\java2021spring\s?= =?UTF-8?q?rc.=20=E7=AC=AC=E4=BA=94=E6=AC=A1=E6=8F=90=E4=BA=A4=EF=BC=8C?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E4=BA=86+=E5=92=8C-=20=E5=92=8C*=E5=92=8C/?= =?UTF-8?q?=E5=92=8C%=E5=92=8Csqrt=E5=92=8CMC=E5=92=8CC=E5=92=8C1/x?= =?UTF-8?q?=E5=92=8C+/-=E5=92=8C=3D=E5=92=8Ce=E5=92=8Cpi=E5=92=8CBac?= =?UTF-8?q?=E5=92=8Cx=E7=9A=84=E5=B9=B3=E6=96=B9=E3=80=81=E4=B8=89?= =?UTF-8?q?=E6=AC=A1=E6=96=B9=E5=92=8C=E4=BA=94=E6=AC=A1=E6=96=B9=E7=9A=84?= =?UTF-8?q?=E8=BF=90=E7=AE=97=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "C:\\Users\\admin\\git\\java2021spring\\src" | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 "C:\\Users\\admin\\git\\java2021spring\\src" diff --git "a/C:\\Users\\admin\\git\\java2021spring\\src" "b/C:\\Users\\admin\\git\\java2021spring\\src" new file mode 100644 index 0000000..e69de29 -- Gitee From f659a78793c7dc82498d057da4d50d6ffca019e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=94=90=E7=9D=BF?= <2475574364@qq.com> Date: Thu, 10 Jun 2021 04:18:24 +0800 Subject: [PATCH 11/16] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20C:?= =?UTF-8?q?\Users\admin\git\java2021spring\src?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "C:\\Users\\admin\\git\\java2021spring\\src" | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 "C:\\Users\\admin\\git\\java2021spring\\src" diff --git "a/C:\\Users\\admin\\git\\java2021spring\\src" "b/C:\\Users\\admin\\git\\java2021spring\\src" deleted file mode 100644 index e69de29..0000000 -- Gitee From 16fb6bb4baf93e77bd868017c0832c820d493be3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=94=90=E7=9D=BF?= <2475574364@qq.com> Date: Thu, 10 Jun 2021 04:19:29 +0800 Subject: [PATCH 12/16] =?UTF-8?q?add=20=E7=AC=AC=E4=BA=94=E6=AC=A1?= =?UTF-8?q?=E6=8F=90=E4=BA=A4.=20=E7=AC=AC=E4=BA=94=E6=AC=A1=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=EF=BC=8C=E5=AE=9E=E7=8E=B0=E4=BA=86+=E5=92=8C-=20?= =?UTF-8?q?=E5=92=8C*=E5=92=8C/=E5=92=8C%=E5=92=8Csqrt=E5=92=8CMC=E5=92=8C?= =?UTF-8?q?C=E5=92=8C1/x=E5=92=8C+/-=E5=92=8C=3D=E5=92=8Ce=E5=92=8Cpi?= =?UTF-8?q?=E5=92=8CBac=E5=92=8Cx=E7=9A=84=E5=B9=B3=E6=96=B9=E3=80=81?= =?UTF-8?q?=E4=B8=89=E6=AC=A1=E6=96=B9=E5=92=8C=E4=BA=94=E6=AC=A1=E6=96=B9?= =?UTF-8?q?=E7=9A=84=E8=BF=90=E7=AE=97=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...2\224\346\254\241\346\217\220\344\272\244" | 484 ++++++++++++++++++ 1 file changed, 484 insertions(+) create mode 100644 "\347\254\254\344\272\224\346\254\241\346\217\220\344\272\244" diff --git "a/\347\254\254\344\272\224\346\254\241\346\217\220\344\272\244" "b/\347\254\254\344\272\224\346\254\241\346\217\220\344\272\244" new file mode 100644 index 0000000..63a81ec --- /dev/null +++ "b/\347\254\254\344\272\224\346\254\241\346\217\220\344\272\244" @@ -0,0 +1,484 @@ +package calculator; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.lang.reflect.Array; +import java.math.BigDecimal; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.GridLayout; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; + +import java2020spring.Const; + +import java.util.Scanner; + +public class Calculator extends JFrame implements ActionListener{ + private static final long serialVersionUID = 1L; + private static final String COMMANDS = null; + private static final Icon[] COMMAND = null; + private static final String M = null; + public static void main(String[] args) { + Calculator calculator=new Calculator(); + calculator.setVisible(true); + } + + public Calculator() throws HeadlessException { + super("Caculator"); + resultText.setAlignmentX(RIGHT_ALIGNMENT); + this.setTitle(Const.TITLE); + this.setSize(Const.FRAME_W,Const.FRAME_H); + this.setLayout(new BorderLayout()); + this.setLocation(Const.FRAME_X,Const.FRAME_Y); + this.setResizable(false); + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + resultText.setBounds(20,18,255,115); + resultText.setAlignmentX(RIGHT_ALIGNMENT); + resultText.setEditable(false); + History.setBounds(290,40,250,370); + History.setAlignmentX(LEFT_ALIGNMENT); + History.setEditable(false); + label.setBounds(400,15,100,20); + j1.setBounds(20,18,320,115); + j1.setLayout(new GridLayout()); + j2.setBounds(380,40,250,380); + j2.setLayout(new GridLayout()); + resultText.setLineWrap(true); + resultText.setWrapStyleWord(true); + History.setLineWrap(true); + History.setWrapStyleWord(true); + g1.setViewportView(resultText); + g1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + g2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + g2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + g2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + j1.add(g1); + j2.add(g2); + this.add(j1); + this.add(j2); + this.setLayout(null); + this.add(label); + int x=20,y=150; + for (int i=0;i=0) + { + c =""; + for(;i=0;i++) + { + c=c+str.charAt(i); + } + i--; + postQueue[f]=c; + f++; + } else if("(".indexOf(str.charAt(i))>=0) + { + d++; + opStack[d]=str.charAt(i); + } + else if(")".indexOf(str.charAt(i))>=0) + { + for(;;) + { + if(opStack[d]!='(') + { + postQueue[f]=opStack[d]+""; + f++; + d--; + } + else + { + d--; + break; + } + } + } + if("*%/".indexOf(str.charAt(i))>=0) + { + if(d==-1) + { + d++; + opStack[d]=str.charAt(i); + } else { + if ("*%/".indexOf(opStack[d])>=0) + { + postQueue[f]=opStack[d]+""; + f++; + opStack[d]=str.charAt(i); + } + else if("(".indexOf(opStack[d])>=0) + { + d++; + opStack[d]=str.charAt(i); + } + else if("+-".indexOf(str.charAt(i))>=0) { + postQueue[f]=opStack[d] + ""; + f++; + opStack[d]=str.charAt(i); + } + } + } + else if("+-".indexOf(str.charAt(i))>=0) + { + if(d==-1) + { + d++; + opStack[d]=str.charAt(i); + } + else { + if("*%/".indexOf(opStack[d])>=0) + { + postQueue[f]=opStack[d]+""; + f++; + opStack[d]=str.charAt(i); + } + else if("(".indexOf(opStack[d])>=0) + { + d++; + opStack[d]=str.charAt(i); + } + else if("+-".indexOf(str.charAt(i))>=0) + { + postQueue[f]=opStack[d]+""; + f++; + opStack[d]= str.charAt(i); + } + } + } + } + for(;d!=-1;) + { + postQueue[f]=opStack[d]+""; + f++; + d--; + } + return postQueue; + } + + public String Result(String str[]) { + String Result[]=new String[100]; + int d=-1; + for (int i=0;str[i]!=null;i++) + { + if ("+-*%/".indexOf(str[i])<0) + { + d++; + Result[d]=str[i]; + } + if ("+-*%/".indexOf(str[i])>=0) + { + double x,y,n; + x=Double.parseDouble(Result[d]); + d--; + y=Double.parseDouble(Result[d]); + d--; + if ("-".indexOf(str[i])>=0) { + n=y-x; + d++; + Result[d]=String.valueOf(n); + } + if ("+".indexOf(str[i])>=0) { + n=y+x; + d++; + Result[d]=String.valueOf(n); + } + if ("*".indexOf(str[i])>=0) { + n=y*x; + d++; + Result[d]=String.valueOf(n); + + } + if ("/".indexOf(str[i])>=0) + { + if (x==0) + { + String s="error!"; + return s; + } + else { + n=y/x; + d++; + Result[d]=String.valueOf(n); + } + } + if("%".indexOf(str[i])>=0) + { + if (x==0) + { + String s="error!"; + return s; + } + else { + n=y%x; + d++; + Result[d]=String.valueOf(n); + } + } + + } + } + return Result[d]; + } + + public String kfys(String str) { + String result=""; + double a=Double.parseDouble(str),b=0; + b=Math.sqrt(a); + result=String.valueOf(b);//灏嗚繍绠楃粨鏋滆浆鎹负string绫诲瀷骞惰祴缁檚tring绫诲瀷鐨勫彉閲弐esult + return result; + } + + public String pfys(String str) { + String result=""; + double a=Double.parseDouble(str),b=0; + b=Math.pow(a,2); + result=String.valueOf(b); + return result; + } + + public String op(String str) { + String result=""; + double a=Double.parseDouble(str),b=0; + b=-a; + result=String.valueOf(b); + return result; + } + + public String ba(String str) + { + String l=resultText.getText(); + l=l.substring(0,l.length()-1); + return l; + } + + public String pyf(String str) { + String result=""; + double a=Double.parseDouble(str),b=0; + b=Math.pow(a,3); + result=String.valueOf(b); + return result; + } + + public String j(String str) { + String result=""; + double a=Double.parseDouble(str),b=0; + b=Math.pow(a,5); + result=String.valueOf(b); + return result; + } + + private String p(String a2) { + // TODO 鑷姩鐢熸垚鐨勬柟娉曞瓨鏍 + return null; + } + + private String k(String a2) { + // TODO 鑷姩鐢熸垚鐨勬柟娉曞瓨鏍 + return null; + } + + public static String getCommands() { + return COMMANDS; + } + + public static Icon[] getCommand() { + return COMMAND; + } + + public static String getM() { + return M; + } + + public JButton[] getCommands2() { + return commands2; + } + + public void setCommands2(JButton[] commands2) { + this.commands2 = commands2; + } + + public Array[] getMs() { + return ms; + } + + public void setMs(Array[] ms) { + this.ms = ms; + } + + public JButton[] getMs2() { + return ms2; + } + + public void setMs2(JButton[] ms2) { + this.ms2 = ms2; + } +} + + + + -- Gitee From 359ecfeaf4f282fae4d8fdd45941950aaac47d55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=94=90=E7=9D=BF?= <2475574364@qq.com> Date: Thu, 10 Jun 2021 08:37:55 +0800 Subject: [PATCH 13/16] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20?= =?UTF-8?q?=E7=AC=AC=E4=BA=94=E6=AC=A1=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...2\224\346\254\241\346\217\220\344\272\244" | 484 ------------------ 1 file changed, 484 deletions(-) delete mode 100644 "\347\254\254\344\272\224\346\254\241\346\217\220\344\272\244" diff --git "a/\347\254\254\344\272\224\346\254\241\346\217\220\344\272\244" "b/\347\254\254\344\272\224\346\254\241\346\217\220\344\272\244" deleted file mode 100644 index 63a81ec..0000000 --- "a/\347\254\254\344\272\224\346\254\241\346\217\220\344\272\244" +++ /dev/null @@ -1,484 +0,0 @@ -package calculator; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.lang.reflect.Array; -import java.math.BigDecimal; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.GridLayout; -import javax.swing.JButton; -import javax.swing.JFrame; -import javax.swing.JPanel; - -import java2020spring.Const; - -import java.util.Scanner; - -public class Calculator extends JFrame implements ActionListener{ - private static final long serialVersionUID = 1L; - private static final String COMMANDS = null; - private static final Icon[] COMMAND = null; - private static final String M = null; - public static void main(String[] args) { - Calculator calculator=new Calculator(); - calculator.setVisible(true); - } - - public Calculator() throws HeadlessException { - super("Caculator"); - resultText.setAlignmentX(RIGHT_ALIGNMENT); - this.setTitle(Const.TITLE); - this.setSize(Const.FRAME_W,Const.FRAME_H); - this.setLayout(new BorderLayout()); - this.setLocation(Const.FRAME_X,Const.FRAME_Y); - this.setResizable(false); - this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - resultText.setBounds(20,18,255,115); - resultText.setAlignmentX(RIGHT_ALIGNMENT); - resultText.setEditable(false); - History.setBounds(290,40,250,370); - History.setAlignmentX(LEFT_ALIGNMENT); - History.setEditable(false); - label.setBounds(400,15,100,20); - j1.setBounds(20,18,320,115); - j1.setLayout(new GridLayout()); - j2.setBounds(380,40,250,380); - j2.setLayout(new GridLayout()); - resultText.setLineWrap(true); - resultText.setWrapStyleWord(true); - History.setLineWrap(true); - History.setWrapStyleWord(true); - g1.setViewportView(resultText); - g1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); - g2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); - g2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); - g2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); - j1.add(g1); - j2.add(g2); - this.add(j1); - this.add(j2); - this.setLayout(null); - this.add(label); - int x=20,y=150; - for (int i=0;i=0) - { - c =""; - for(;i=0;i++) - { - c=c+str.charAt(i); - } - i--; - postQueue[f]=c; - f++; - } else if("(".indexOf(str.charAt(i))>=0) - { - d++; - opStack[d]=str.charAt(i); - } - else if(")".indexOf(str.charAt(i))>=0) - { - for(;;) - { - if(opStack[d]!='(') - { - postQueue[f]=opStack[d]+""; - f++; - d--; - } - else - { - d--; - break; - } - } - } - if("*%/".indexOf(str.charAt(i))>=0) - { - if(d==-1) - { - d++; - opStack[d]=str.charAt(i); - } else { - if ("*%/".indexOf(opStack[d])>=0) - { - postQueue[f]=opStack[d]+""; - f++; - opStack[d]=str.charAt(i); - } - else if("(".indexOf(opStack[d])>=0) - { - d++; - opStack[d]=str.charAt(i); - } - else if("+-".indexOf(str.charAt(i))>=0) { - postQueue[f]=opStack[d] + ""; - f++; - opStack[d]=str.charAt(i); - } - } - } - else if("+-".indexOf(str.charAt(i))>=0) - { - if(d==-1) - { - d++; - opStack[d]=str.charAt(i); - } - else { - if("*%/".indexOf(opStack[d])>=0) - { - postQueue[f]=opStack[d]+""; - f++; - opStack[d]=str.charAt(i); - } - else if("(".indexOf(opStack[d])>=0) - { - d++; - opStack[d]=str.charAt(i); - } - else if("+-".indexOf(str.charAt(i))>=0) - { - postQueue[f]=opStack[d]+""; - f++; - opStack[d]= str.charAt(i); - } - } - } - } - for(;d!=-1;) - { - postQueue[f]=opStack[d]+""; - f++; - d--; - } - return postQueue; - } - - public String Result(String str[]) { - String Result[]=new String[100]; - int d=-1; - for (int i=0;str[i]!=null;i++) - { - if ("+-*%/".indexOf(str[i])<0) - { - d++; - Result[d]=str[i]; - } - if ("+-*%/".indexOf(str[i])>=0) - { - double x,y,n; - x=Double.parseDouble(Result[d]); - d--; - y=Double.parseDouble(Result[d]); - d--; - if ("-".indexOf(str[i])>=0) { - n=y-x; - d++; - Result[d]=String.valueOf(n); - } - if ("+".indexOf(str[i])>=0) { - n=y+x; - d++; - Result[d]=String.valueOf(n); - } - if ("*".indexOf(str[i])>=0) { - n=y*x; - d++; - Result[d]=String.valueOf(n); - - } - if ("/".indexOf(str[i])>=0) - { - if (x==0) - { - String s="error!"; - return s; - } - else { - n=y/x; - d++; - Result[d]=String.valueOf(n); - } - } - if("%".indexOf(str[i])>=0) - { - if (x==0) - { - String s="error!"; - return s; - } - else { - n=y%x; - d++; - Result[d]=String.valueOf(n); - } - } - - } - } - return Result[d]; - } - - public String kfys(String str) { - String result=""; - double a=Double.parseDouble(str),b=0; - b=Math.sqrt(a); - result=String.valueOf(b);//灏嗚繍绠楃粨鏋滆浆鎹负string绫诲瀷骞惰祴缁檚tring绫诲瀷鐨勫彉閲弐esult - return result; - } - - public String pfys(String str) { - String result=""; - double a=Double.parseDouble(str),b=0; - b=Math.pow(a,2); - result=String.valueOf(b); - return result; - } - - public String op(String str) { - String result=""; - double a=Double.parseDouble(str),b=0; - b=-a; - result=String.valueOf(b); - return result; - } - - public String ba(String str) - { - String l=resultText.getText(); - l=l.substring(0,l.length()-1); - return l; - } - - public String pyf(String str) { - String result=""; - double a=Double.parseDouble(str),b=0; - b=Math.pow(a,3); - result=String.valueOf(b); - return result; - } - - public String j(String str) { - String result=""; - double a=Double.parseDouble(str),b=0; - b=Math.pow(a,5); - result=String.valueOf(b); - return result; - } - - private String p(String a2) { - // TODO 鑷姩鐢熸垚鐨勬柟娉曞瓨鏍 - return null; - } - - private String k(String a2) { - // TODO 鑷姩鐢熸垚鐨勬柟娉曞瓨鏍 - return null; - } - - public static String getCommands() { - return COMMANDS; - } - - public static Icon[] getCommand() { - return COMMAND; - } - - public static String getM() { - return M; - } - - public JButton[] getCommands2() { - return commands2; - } - - public void setCommands2(JButton[] commands2) { - this.commands2 = commands2; - } - - public Array[] getMs() { - return ms; - } - - public void setMs(Array[] ms) { - this.ms = ms; - } - - public JButton[] getMs2() { - return ms2; - } - - public void setMs2(JButton[] ms2) { - this.ms2 = ms2; - } -} - - - - -- Gitee From 1e7eae8d6de49e95fb2adc97f52657f280953664 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=94=90=E7=9D=BF?= <2475574364@qq.com> Date: Thu, 10 Jun 2021 08:57:51 +0800 Subject: [PATCH 14/16] =?UTF-8?q?add=20=E8=AE=A1=E7=AE=97=E5=99=A8?= =?UTF-8?q?=E7=AC=AC=E4=BA=94=E6=AC=A1=E6=8F=90=E4=BA=A4.=20=E7=AC=AC?= =?UTF-8?q?=E4=BA=94=E6=AC=A1=E6=8F=90=E4=BA=A4=EF=BC=8C=E5=B0=86MR?= =?UTF-8?q?=EF=BC=8CMS=EF=BC=8CM+=E6=94=B9=E6=88=90pi=EF=BC=88=CF=80?= =?UTF-8?q?=EF=BC=89=EF=BC=8Cx^3=EF=BC=8Cx^5=E3=80=82=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E4=BA=86=E5=8A=A0=E5=87=8F=E4=B9=98=E9=99=A4=E5=92=8Csqrt?= =?UTF-8?q?=E5=92=8C%=E5=92=8C1/x=E5=92=8C=E5=8F=96=E7=9B=B8=E5=8F=8D?= =?UTF-8?q?=E6=95=B0=E5=92=8Ce=E5=92=8Cpi=E5=92=8Cx=E7=9A=84=E5=B9=B3?= =?UTF-8?q?=E6=96=B9=E5=92=8Cx=E7=9A=84=E4=B8=89=E6=AC=A1=E6=96=B9?= =?UTF-8?q?=E5=92=8Cx=E7=9A=84=E4=BA=94=E6=AC=A1=E6=96=B9=E5=92=8CBac?= =?UTF-8?q?=E5=92=8CC=E5=92=8CMC=E7=9A=84=E8=BF=90=E7=AE=97=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...2\224\346\254\241\346\217\220\344\272\244" | 481 ++++++++++++++++++ 1 file changed, 481 insertions(+) create mode 100644 "\350\256\241\347\256\227\345\231\250\347\254\254\344\272\224\346\254\241\346\217\220\344\272\244" diff --git "a/\350\256\241\347\256\227\345\231\250\347\254\254\344\272\224\346\254\241\346\217\220\344\272\244" "b/\350\256\241\347\256\227\345\231\250\347\254\254\344\272\224\346\254\241\346\217\220\344\272\244" new file mode 100644 index 0000000..af3d3d9 --- /dev/null +++ "b/\350\256\241\347\256\227\345\231\250\347\254\254\344\272\224\346\254\241\346\217\220\344\272\244" @@ -0,0 +1,481 @@ +package calculator; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.lang.reflect.Array; +import java.math.BigDecimal; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.GridLayout; +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JPanel; + +import java2020spring.Const; + +import java.util.Scanner; + +public class Calculator extends JFrame implements ActionListener{ + private static final long serialVersionUID = 1L; + private static final String COMMANDS = null; + private static final Icon[] COMMAND = null; + private static final String M = null; + public static void main(String[] args) { + Calculator calculator=new Calculator(); + calculator.setVisible(true); + } + + public Calculator() throws HeadlessException { + super("Caculator"); + resultText.setAlignmentX(RIGHT_ALIGNMENT); + this.setTitle(Const.TITLE); + this.setSize(Const.FRAME_W,Const.FRAME_H); + this.setLayout(new BorderLayout()); + this.setLocation(Const.FRAME_X,Const.FRAME_Y); + this.setResizable(false); + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + resultText.setBounds(20,18,255,115); + resultText.setAlignmentX(RIGHT_ALIGNMENT); + resultText.setEditable(false); + History.setBounds(290,40,250,370); + History.setAlignmentX(LEFT_ALIGNMENT); + History.setEditable(false); + label.setBounds(400,15,100,20); + j1.setBounds(20,18,320,115); + j1.setLayout(new GridLayout()); + j2.setBounds(380,40,250,380); + j2.setLayout(new GridLayout()); + resultText.setLineWrap(true); + resultText.setWrapStyleWord(true); + History.setLineWrap(true); + History.setWrapStyleWord(true); + g1.setViewportView(resultText); + g1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + g2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + g2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + g2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + j1.add(g1); + j2.add(g2); + this.add(j1); + this.add(j2); + this.setLayout(null); + this.add(label); + int x=20,y=150; + for (int i=0;i=0) + { + c =""; + for(;i=0;i++) + { + c=c+str.charAt(i); + } + i--; + postQueue[f]=c; + f++; + } else if("(".indexOf(str.charAt(i))>=0) + { + d++; + opStack[d]=str.charAt(i); + } + else if(")".indexOf(str.charAt(i))>=0) + { + for(;;) + { + if(opStack[d]!='(') + { + postQueue[f]=opStack[d]+""; + f++; + d--; + } + else + { + d--; + break; + } + } + } + if("*%/".indexOf(str.charAt(i))>=0) + { + if(d==-1) + { + d++; + opStack[d]=str.charAt(i); + } else { + if ("*%/".indexOf(opStack[d])>=0) + { + postQueue[f]=opStack[d]+""; + f++; + opStack[d]=str.charAt(i); + } + else if("(".indexOf(opStack[d])>=0) + { + d++; + opStack[d]=str.charAt(i); + } + else if("+-".indexOf(str.charAt(i))>=0) { + postQueue[f]=opStack[d] + ""; + f++; + opStack[d]=str.charAt(i); + } + } + } + else if("+-".indexOf(str.charAt(i))>=0) + { + if(d==-1) + { + d++; + opStack[d]=str.charAt(i); + } + else { + if("*%/".indexOf(opStack[d])>=0) + { + postQueue[f]=opStack[d]+""; + f++; + opStack[d]=str.charAt(i); + } + else if("(".indexOf(opStack[d])>=0) + { + d++; + opStack[d]=str.charAt(i); + } + else if("+-".indexOf(str.charAt(i))>=0) + { + postQueue[f]=opStack[d]+""; + f++; + opStack[d]= str.charAt(i); + } + } + } + } + for(;d!=-1;) + { + postQueue[f]=opStack[d]+""; + f++; + d--; + } + return postQueue; + } + + public String Result(String str[]) { + String Result[]=new String[100]; + int d=-1; + for (int i=0;str[i]!=null;i++) + { + if ("+-*%/".indexOf(str[i])<0) + { + d++; + Result[d]=str[i]; + } + if ("+-*%/".indexOf(str[i])>=0) + { + double x,y,n; + x=Double.parseDouble(Result[d]); + d--; + y=Double.parseDouble(Result[d]); + d--; + if ("-".indexOf(str[i])>=0) { + n=y-x; + d++; + Result[d]=String.valueOf(n); + } + if ("+".indexOf(str[i])>=0) { + n=y+x; + d++; + Result[d]=String.valueOf(n); + } + if ("*".indexOf(str[i])>=0) { + n=y*x; + d++; + Result[d]=String.valueOf(n); + + } + if ("/".indexOf(str[i])>=0) + { + if (x==0) + { + String s="error!"; + return s; + } + else { + n=y/x; + d++; + Result[d]=String.valueOf(n); + } + } + if("%".indexOf(str[i])>=0) + { + if (x==0) + { + String s="error!"; + return s; + } + else { + n=y%x; + d++; + Result[d]=String.valueOf(n); + } + } + + } + } + return Result[d]; + } + + public String kfys(String str) { + String result=""; + double a=Double.parseDouble(str),b=0; + b=Math.sqrt(a); + result=String.valueOf(b); + return result; + } + + public String pfys(String str) { + String result=""; + double a=Double.parseDouble(str),b=0; + b=Math.pow(a,2); + result=String.valueOf(b); + return result; + } + + public String op(String str) { + String result=""; + double a=Double.parseDouble(str),b=0; + b=-a; + result=String.valueOf(b); + return result; + } + + public String ba(String str) + { + String l=resultText.getText(); + l=l.substring(0,l.length()-1); + return l; + } + + public String pyf(String str) { + String result=""; + double a=Double.parseDouble(str),b=0; + b=Math.pow(a,3); + result=String.valueOf(b); + return result; + } + + public String j(String str) { + String result=""; + double a=Double.parseDouble(str),b=0; + b=Math.pow(a,5); + result=String.valueOf(b); + return result; + } + + private String p(String a2) { + // TODO 鑷姩鐢熸垚鐨勬柟娉曞瓨鏍 + return null; + } + + private String k(String a2) { + // TODO 鑷姩鐢熸垚鐨勬柟娉曞瓨鏍 + return null; + } + + public static String getCommands() { + return COMMANDS; + } + + public static Icon[] getCommand() { + return COMMAND; + } + + public static String getM() { + return M; + } + + public JButton[] getCommands2() { + return commands2; + } + + public void setCommands2(JButton[] commands2) { + this.commands2 = commands2; + } + + public Array[] getMs() { + return ms; + } + + public void setMs(Array[] ms) { + this.ms = ms; + } + + public JButton[] getMs2() { + return ms2; + } + + public void setMs2(JButton[] ms2) { + this.ms2 = ms2; + } +} + -- Gitee From 8b53f5d896dc55da9907dbc69bd2284fc249575b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=94=90=E7=9D=BF?= <2475574364@qq.com> Date: Thu, 10 Jun 2021 11:26:13 +0800 Subject: [PATCH 15/16] =?UTF-8?q?=E6=96=B0=E5=BB=BA=20=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E5=99=A8=E7=AC=AC=E5=85=AD=E6=AC=A1=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../.keep" | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 "\350\256\241\347\256\227\345\231\250\347\254\254\345\205\255\346\254\241\346\217\220\344\272\244/.keep" diff --git "a/\350\256\241\347\256\227\345\231\250\347\254\254\345\205\255\346\254\241\346\217\220\344\272\244/.keep" "b/\350\256\241\347\256\227\345\231\250\347\254\254\345\205\255\346\254\241\346\217\220\344\272\244/.keep" new file mode 100644 index 0000000..e69de29 -- Gitee From 32ccfa20cd8ff77b3b4bedaab1ebe8717f8341bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=94=90=E7=9D=BF?= <2475574364@qq.com> Date: Thu, 10 Jun 2021 11:30:09 +0800 Subject: [PATCH 16/16] =?UTF-8?q?=E7=AC=AC=E5=85=AD=E6=AC=A1=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=EF=BC=8C=E5=AF=B9=E6=95=B4=E4=B8=AA=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E4=BA=86=E4=BC=98=E5=8C=96=EF=BC=8C=E9=99=A4?= =?UTF-8?q?=E5=8E=BB=E4=BA=86=E6=9C=AA=E4=BD=BF=E7=94=A8=E7=9A=84=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E5=B9=B6=E4=B8=94=E9=99=A4=E5=8E=BB=E4=BA=86=E6=96=B9?= =?UTF-8?q?=E6=B3=95p=E5=92=8C=E6=96=B9=E6=B3=95k=E3=80=82=20=E7=AC=AC?= =?UTF-8?q?=E5=85=AD=E6=AC=A1=E6=8F=90=E4=BA=A4=EF=BC=8C=E5=AF=B9=E6=95=B4?= =?UTF-8?q?=E4=B8=AA=E9=A1=B9=E7=9B=AE=E8=BF=9B=E8=A1=8C=E4=BA=86=E4=BC=98?= =?UTF-8?q?=E5=8C=96=EF=BC=8C=E9=99=A4=E5=8E=BB=E4=BA=86=E6=9C=AA=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E7=9A=84=E5=AF=BC=E5=85=A5=E5=B9=B6=E4=B8=94=E9=99=A4?= =?UTF-8?q?=E5=8E=BB=E4=BA=86=E6=96=B9=E6=B3=95p=E5=92=8C=E6=96=B9?= =?UTF-8?q?=E6=B3=95k=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../calculator/Calculator.java" | 469 ++++++++++++++++++ .../java2020spring/Const.java" | 14 + .../java2020spring/resultText.java" | 17 + 3 files changed, 500 insertions(+) create mode 100644 "\350\256\241\347\256\227\345\231\250\347\254\254\345\205\255\346\254\241\346\217\220\344\272\244/calculator/Calculator.java" create mode 100644 "\350\256\241\347\256\227\345\231\250\347\254\254\345\205\255\346\254\241\346\217\220\344\272\244/java2020spring/Const.java" create mode 100644 "\350\256\241\347\256\227\345\231\250\347\254\254\345\205\255\346\254\241\346\217\220\344\272\244/java2020spring/resultText.java" diff --git "a/\350\256\241\347\256\227\345\231\250\347\254\254\345\205\255\346\254\241\346\217\220\344\272\244/calculator/Calculator.java" "b/\350\256\241\347\256\227\345\231\250\347\254\254\345\205\255\346\254\241\346\217\220\344\272\244/calculator/Calculator.java" new file mode 100644 index 0000000..e1a68f1 --- /dev/null +++ "b/\350\256\241\347\256\227\345\231\250\347\254\254\345\205\255\346\254\241\346\217\220\344\272\244/calculator/Calculator.java" @@ -0,0 +1,469 @@ +package calculator; + +import javax.swing.*; + +import java2020spring.Const; + +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.lang.reflect.Array; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.GridLayout; + +public class Calculator extends JFrame implements ActionListener{ + + private static final long serialVersionUID = 1L; + private static final String COMMANDS = null; + private static final Icon[] COMMAND = null; + private static final String M = null; + public static void main(String[] args) { + Calculator calculator=new Calculator(); + calculator.setVisible(true); + } + + public Calculator() throws HeadlessException { + super("Caculator"); + resultText.setAlignmentX(RIGHT_ALIGNMENT); + this.setTitle(Const.TITLE); + this.setSize(Const.FRAME_W,Const.FRAME_H); + this.setLayout(new BorderLayout()); + this.setLocation(Const.FRAME_X,Const.FRAME_Y); + this.setResizable(false); + this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + resultText.setBounds(20,18,255,115); + resultText.setAlignmentX(RIGHT_ALIGNMENT); + resultText.setEditable(false); + History.setBounds(290,40,250,370); + History.setAlignmentX(LEFT_ALIGNMENT); + History.setEditable(false); + label.setBounds(400,15,100,20); + j1.setBounds(20,18,320,115); + j1.setLayout(new GridLayout()); + j2.setBounds(380,40,250,380); + j2.setLayout(new GridLayout()); + resultText.setLineWrap(true); + resultText.setWrapStyleWord(true); + History.setLineWrap(true); + History.setWrapStyleWord(true); + g1.setViewportView(resultText); + g1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + g2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + g2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); + g2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); + j1.add(g1); + j2.add(g2); + this.add(j1); + this.add(j2); + this.setLayout(null); + this.add(label); + int x=20,y=150; + for (int i=0;i=0) + { + c =""; + for(;i=0;i++) + { + c=c+str.charAt(i); + } + i--; + postQueue[f]=c; + f++; + } else if("(".indexOf(str.charAt(i))>=0) + { + d++; + opStack[d]=str.charAt(i); + } + else if(")".indexOf(str.charAt(i))>=0) + { + for(;;) + { + if(opStack[d]!='(') + { + postQueue[f]=opStack[d]+""; + f++; + d--; + } + else + { + d--; + break; + } + } + } + if("*%/".indexOf(str.charAt(i))>=0) + { + if(d==-1) + { + d++; + opStack[d]=str.charAt(i); + } else { + if ("*%/".indexOf(opStack[d])>=0) + { + postQueue[f]=opStack[d]+""; + f++; + opStack[d]=str.charAt(i); + } + else if("(".indexOf(opStack[d])>=0) + { + d++; + opStack[d]=str.charAt(i); + } + else if("+-".indexOf(str.charAt(i))>=0) { + postQueue[f]=opStack[d] + ""; + f++; + opStack[d]=str.charAt(i); + } + } + } + else if("+-".indexOf(str.charAt(i))>=0) + { + if(d==-1) + { + d++; + opStack[d]=str.charAt(i); + } + else { + if("*%/".indexOf(opStack[d])>=0) + { + postQueue[f]=opStack[d]+""; + f++; + opStack[d]=str.charAt(i); + } + else if("(".indexOf(opStack[d])>=0) + { + d++; + opStack[d]=str.charAt(i); + } + else if("+-".indexOf(str.charAt(i))>=0) + { + postQueue[f]=opStack[d]+""; + f++; + opStack[d]= str.charAt(i); + } + } + } + } + for(;d!=-1;) + { + postQueue[f]=opStack[d]+""; + f++; + d--; + } + return postQueue; + } + + public String Result(String str[]) { + String Result[]=new String[100]; + int d=-1; + for (int i=0;str[i]!=null;i++) + { + if ("+-*%/".indexOf(str[i])<0) + { + d++; + Result[d]=str[i]; + } + if ("+-*%/".indexOf(str[i])>=0) + { + double x,y,n; + x=Double.parseDouble(Result[d]); + d--; + y=Double.parseDouble(Result[d]); + d--; + if ("-".indexOf(str[i])>=0) { + n=y-x; + d++; + Result[d]=String.valueOf(n); + } + if ("+".indexOf(str[i])>=0) { + n=y+x; + d++; + Result[d]=String.valueOf(n); + } + if ("*".indexOf(str[i])>=0) { + n=y*x; + d++; + Result[d]=String.valueOf(n); + + } + if ("/".indexOf(str[i])>=0) + { + if (x==0) + { + String s="error!"; + return s; + } + else { + n=y/x; + d++; + Result[d]=String.valueOf(n); + } + } + if("%".indexOf(str[i])>=0) + { + if (x==0) + { + String s="error!"; + return s; + } + else { + n=y%x; + d++; + Result[d]=String.valueOf(n); + } + } + + } + } + return Result[d]; + } + + public String kfys(String str) { + String result=""; + double a=Double.parseDouble(str),b=0; + b=Math.sqrt(a); + result=String.valueOf(b); + return result; + } + + public String pfys(String str) { + String result=""; + double a=Double.parseDouble(str),b=0; + b=Math.pow(a,2); + result=String.valueOf(b); + return result; + } + + public String op(String str) { + String result=""; + double a=Double.parseDouble(str),b=0; + b=-a; + result=String.valueOf(b); + return result; + } + + public String ba(String str) + { + String l=resultText.getText(); + l=l.substring(0,l.length()-1); + return l; + } + + public String pyf(String str) { + String result=""; + double a=Double.parseDouble(str),b=0; + b=Math.pow(a,3); + result=String.valueOf(b); + return result; + } + + public String j(String str) { + String result=""; + double a=Double.parseDouble(str),b=0; + b=Math.pow(a,5); + result=String.valueOf(b); + return result; + } + + public static String getCommands() { + return COMMANDS; + } + + public static Icon[] getCommand() { + return COMMAND; + } + + public static String getM() { + return M; + } + + public JButton[] getCommands2() { + return commands2; + } + + public void setCommands2(JButton[] commands2) { + this.commands2 = commands2; + } + + public Array[] getMs() { + return ms; + } + + public void setMs(Array[] ms) { + this.ms = ms; + } + + public JButton[] getMs2() { + return ms2; + } + + public void setMs2(JButton[] ms2) { + this.ms2 = ms2; + } +} + + + + diff --git "a/\350\256\241\347\256\227\345\231\250\347\254\254\345\205\255\346\254\241\346\217\220\344\272\244/java2020spring/Const.java" "b/\350\256\241\347\256\227\345\231\250\347\254\254\345\205\255\346\254\241\346\217\220\344\272\244/java2020spring/Const.java" new file mode 100644 index 0000000..32cb283 --- /dev/null +++ "b/\350\256\241\347\256\227\345\231\250\347\254\254\345\205\255\346\254\241\346\217\220\344\272\244/java2020spring/Const.java" @@ -0,0 +1,14 @@ +package java2020spring; + +import java.awt.*; + +public class Const { + public static final int FRAME_W=300; + public static final int FRAME_H=300; + public static final int SCREEN_W=Toolkit.getDefaultToolkit().getScreenSize().width; + public static final int SCREEN_H=Toolkit.getDefaultToolkit().getScreenSize().height; + public static final int FRAME_X=(SCREEN_W-FRAME_W)/2; + public static final int FRAME_Y=(SCREEN_H-FRAME_H)/2; + public static final String TITLE="计算器"; + +} diff --git "a/\350\256\241\347\256\227\345\231\250\347\254\254\345\205\255\346\254\241\346\217\220\344\272\244/java2020spring/resultText.java" "b/\350\256\241\347\256\227\345\231\250\347\254\254\345\205\255\346\254\241\346\217\220\344\272\244/java2020spring/resultText.java" new file mode 100644 index 0000000..9a0cb4f --- /dev/null +++ "b/\350\256\241\347\256\227\345\231\250\347\254\254\345\205\255\346\254\241\346\217\220\344\272\244/java2020spring/resultText.java" @@ -0,0 +1,17 @@ +package java2020spring; + +import java.awt.Color; + +public class resultText { + + public static void setHorizontalAlignment(int right) { + // TODO 自动生成的方法存根 + + } + + public static void setBackground(Color white) { + // TODO 自动生成的方法存根 + + } + +} -- Gitee