diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..35410cacdc5e87f985c93a96520f5e11a5c822e4
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# 默认忽略的文件
+/shelf/
+/workspace.xml
+# 基于编辑器的 HTTP 客户端请求
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000000000000000000000000000000000000..ebe01736f9211ba9fa43d3a87cc37ca6b91d04d8
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/.idea/.gitignore b/src/.idea/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..35410cacdc5e87f985c93a96520f5e11a5c822e4
--- /dev/null
+++ b/src/.idea/.gitignore
@@ -0,0 +1,8 @@
+# 默认忽略的文件
+/shelf/
+/workspace.xml
+# 基于编辑器的 HTTP 客户端请求
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/src/.idea/misc.xml b/src/.idea/misc.xml
new file mode 100644
index 0000000000000000000000000000000000000000..3d3ab27e979d39d5c546c323365ff06b8f343b4f
--- /dev/null
+++ b/src/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/.idea/modules.xml b/src/.idea/modules.xml
new file mode 100644
index 0000000000000000000000000000000000000000..ea25cb6475b9409a6cd5868ef50ea0cdc7ce9a84
--- /dev/null
+++ b/src/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/.idea/vcs.xml b/src/.idea/vcs.xml
new file mode 100644
index 0000000000000000000000000000000000000000..6c0b8635858dc7ad44b93df54b762707ce49eefc
--- /dev/null
+++ b/src/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/MyCalculator/.idea/misc.xml b/src/MyCalculator/.idea/misc.xml
new file mode 100644
index 0000000000000000000000000000000000000000..639900d13c6182e452e33a3bd638e70a0146c785
--- /dev/null
+++ b/src/MyCalculator/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/MyCalculator/.idea/modules.xml b/src/MyCalculator/.idea/modules.xml
new file mode 100644
index 0000000000000000000000000000000000000000..3718e39b616473557572df167390361cc80aff05
--- /dev/null
+++ b/src/MyCalculator/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/MyCalculator/.idea/vcs.xml b/src/MyCalculator/.idea/vcs.xml
new file mode 100644
index 0000000000000000000000000000000000000000..b2bdec2d71b6a5ce4ae49efc37516809c50e4d5e
--- /dev/null
+++ b/src/MyCalculator/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/MyCalculator/.idea/workspace.xml b/src/MyCalculator/.idea/workspace.xml
new file mode 100644
index 0000000000000000000000000000000000000000..4938aa9c28ef9d49a7c0322f85b6d5c935cca1c6
--- /dev/null
+++ b/src/MyCalculator/.idea/workspace.xml
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {
+ "keyToString": {
+ "RunOnceActivity.OpenProjectViewOnStart": "true",
+ "RunOnceActivity.ShowReadmeOnStart": "true",
+ "WebServerToolWindowFactoryState": "false"
+ }
+}
+
+
+
+
+ 1653317726539
+
+
+ 1653317726539
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git "a/src/MyCalculator/610315-Java\351\235\242\345\220\221\345\257\271\350\261\241\347\250\213\345\272\217\350\256\276\350\256\241\345\256\236\351\252\214-\350\256\276\350\256\241\346\200\247\345\256\236\351\252\214\346\212\245\345\221\212-202125710118-\347\275\227\344\270\200\351\223\255_V3.0.doc" "b/src/MyCalculator/610315-Java\351\235\242\345\220\221\345\257\271\350\261\241\347\250\213\345\272\217\350\256\276\350\256\241\345\256\236\351\252\214-\350\256\276\350\256\241\346\200\247\345\256\236\351\252\214\346\212\245\345\221\212-202125710118-\347\275\227\344\270\200\351\223\255_V3.0.doc"
new file mode 100644
index 0000000000000000000000000000000000000000..cd72523c57930191d1f56858854fbbad21045a48
Binary files /dev/null and "b/src/MyCalculator/610315-Java\351\235\242\345\220\221\345\257\271\350\261\241\347\250\213\345\272\217\350\256\276\350\256\241\345\256\236\351\252\214-\350\256\276\350\256\241\346\200\247\345\256\236\351\252\214\346\212\245\345\221\212-202125710118-\347\275\227\344\270\200\351\223\255_V3.0.doc" differ
diff --git a/src/MyCalculator/Calculator.java b/src/MyCalculator/Calculator.java
new file mode 100644
index 0000000000000000000000000000000000000000..6cce51096023e29329593e6f9e3a8a8d2a3d8e97
--- /dev/null
+++ b/src/MyCalculator/Calculator.java
@@ -0,0 +1,49 @@
+package MyCalculator;
+
+import java.awt.*;
+import java.awt.event.ActionListener;
+import javax.swing.*;
+public class Calculator extends JFrame{
+ JTextField showingTest = new JTextField("0.0");
+ boolean setStutas=false;
+ CalculatorListener listener;
+ private String[] KeyWords = {"(", ")", "-/+", "/", "*", "<-",
+ "^", "X!", "7", "8", "9", "+",
+ "√", "log", "4", "5", "6", "-", "MC", "MR",
+ "1","2","3", "C","M+", "π", "%", "0", ".", "="};
+ private JButton[] keysBottons = new JButton[KeyWords.length];
+ private String exchangeString = "";
+ public Calculator() {
+ setLayout(null);
+ showingTest.setBounds(20, 5, 385, 40);
+ int x = 20, y = 55;
+ showingTest.setEditable(false);
+ showingTest.setHorizontalAlignment(JTextField.RIGHT);
+ listener = new CalculatorListener();
+ listener.setView(this);
+ add(showingTest);
+ for (int i = 0; i < KeyWords.length; i++) {
+ keysBottons[i] = new JButton();
+ keysBottons[i].addActionListener(listener);
+ keysBottons[i].setText(KeyWords[i]);
+ keysBottons[i].setBounds(x, y, 60, 40);
+ if (x < 330) {
+ x += 65;
+ } else {
+ x = 20;
+ y += 45;
+ }
+ this.add(keysBottons[i]);
+ }
+ keysBottons[3].setForeground(Color.blue);
+ keysBottons[4].setForeground(Color.blue);
+ keysBottons[11].setForeground(Color.blue);
+ keysBottons[17].setForeground(Color.blue);
+ keysBottons[29].setForeground(Color.red);
+ setResizable(false);
+ setBounds(940, 70, 445, 350);
+ setDefaultCloseOperation(EXIT_ON_CLOSE);
+ setVisible(true);
+ }
+
+}
diff --git a/src/MyCalculator/CalculatorListener.java b/src/MyCalculator/CalculatorListener.java
new file mode 100644
index 0000000000000000000000000000000000000000..efa856b96f6358ffb01e00bdabb2ef986eeec9d2
--- /dev/null
+++ b/src/MyCalculator/CalculatorListener.java
@@ -0,0 +1,250 @@
+package MyCalculator;
+import java.awt.*;
+import javax.swing.*;
+import java.awt.event.*;
+public class CalculatorListener implements ActionListener {
+ Calculator c;
+ public void setView(Calculator view){
+ c = view;
+ }
+ String storeString = "";//用于存放触发M+后文本框内的数字,
+ // 以实现对于计算结果数据的储存
+ boolean display = false;//用于判断是否已经触发过MR按键
+ String store = "";//临时存放文本框的字符串,用于MR的显示与文本框字符串的还原。
+ String inString = "";//存放真正用于计算的字符串
+ boolean inString_Status = true;//用于判断inString字符串的状态,
+ // 方便判断输入字符按键时是否需要重置instring内原先的数据。
+ @Override
+
+ public void actionPerformed(ActionEvent e) {
+ String sign = e.getActionCommand();
+ if("0123456789.".indexOf(sign)>=0){
+ number_Perform(sign);
+ }
+ else if (sign.equals("<-")) {
+ backSpace_Perform();
+ }
+ else if (sign.equals("C")) {
+ clear_Perform();
+ }
+ else if (sign.equals("π")) {
+ inString += "3.14";
+ inString_Status = true;
+ String str = c.showingTest.getText();
+ if(!c.setStutas){
+ c.showingTest.setText("π");
+ c.setStutas = true;
+ }
+ else {
+ c.showingTest.setText(str += "π");
+ c.setStutas = true;
+ }
+ }
+ else if (sign.equals("log")) {
+ log_Perform();
+ }
+ else if (sign.equals("MC")) {
+ MemoryClean_Perform();
+ }
+ else if (sign.equals("MR")) {
+ ShowMemory_Perform();
+ }
+ else if (sign.equals("M+")) {
+ MemoryPlus_Perform();
+ }
+ else if (sign.equals("X!")) {
+ jiecheng_Perform();
+ }
+ else if (sign.equals("-/+")) {
+ String str = c.showingTest.getText();
+ if(!str.contains("-")){
+ c.showingTest.setText("-"+c.showingTest.getText());
+ inString = "-"+inString;
+ }
+ }
+ else if("()+-*/e%√^π".indexOf(sign)>=0)
+ operation_Perform(sign);
+ else if (sign.equals("=")){
+ result_perform();
+ }
+ }
+ public void log_Perform(){
+ inString += "log(";
+ inString_Status = true;
+ String str = c.showingTest.getText();
+ if(!c.setStutas){
+ c.showingTest.setText("log(");
+ c.setStutas = true;
+ }
+ else {
+ c.showingTest.setText(str += "log(");
+ c.setStutas = true;
+ }
+ }
+ public void clear_Perform(){
+ c.showingTest.setText("0");
+ c.setStutas = false;
+ inString = "";
+ }
+
+ public void number_Perform(String a){
+ String str = c.showingTest.getText();
+ if(!inString_Status)inString = a;
+ else inString += a;
+ if(!c.setStutas){
+ c.showingTest.setText(a);
+ c.setStutas = true;
+ }
+ else {
+ c.showingTest.setText(str += a);
+ c.setStutas = true;
+ }
+ }
+ public void operation_Perform(String a){
+ inString += a;
+ inString_Status = true;
+ String str = c.showingTest.getText();
+ if(!c.setStutas){
+ c.showingTest.setText(a);
+ c.setStutas = true;
+ }
+ else {
+ c.showingTest.setText(str += a);
+ c.setStutas = true;
+ }
+
+ }
+ public void backSpace_Perform(){
+ String str = c.showingTest.getText();
+ int i = str.length();
+ int t = inString.length();
+
+ if(t==0){
+ inString = "";
+ inString_Status = true;
+ }
+ else inString = inString.substring(0,t-1);
+ if(t==0)inString_Status = false;
+
+ if(i!=0){
+ c.showingTest.setText(str.substring(0,i-1));
+ if(str.length()==0){
+ c.showingTest.setText("0");
+ c.setStutas = false;
+ }
+ }
+ if(i==0&& c.setStutas){
+ c.showingTest.setText("0");
+ c.setStutas = false;
+ }
+ if(i==0&& !c.setStutas){
+ c.showingTest.setText("0");
+ }
+ }
+ public void result_perform(){
+ if(inString.length()==0){
+ inString = c.showingTest.getText();
+ }
+ String result = (new stringOperation()).mixedCalculation(inString);
+ inString = result;
+ inString_Status = false;
+ c.showingTest.setText(result);
+ c.setStutas = false;//将文本框内的状态改为false,方便直接输入新的字符。
+ }
+ public void MemoryClean_Perform(){
+ storeString = "";
+ }
+
+ public void ShowMemory_Perform(){
+ if(!display){
+ store = c.showingTest.getText();
+ c.showingTest.setText(storeString);
+ display = true;
+ }
+ else{
+ c.showingTest.setText(store);
+ display = false;
+ }
+
+ }
+
+ public void MemoryPlus_Perform(){
+ if(storeString.length()==0){
+ storeString = c.showingTest.getText();
+ }
+ else {
+ String Opera = inString+"+"+storeString;
+ String result = (new stringOperation()).mixedCalculation(Opera);
+ inString = result;
+ storeString = result;
+ c.showingTest.setText(result);
+ }
+ }
+ public void jiecheng_Perform() {
+ String str = c.showingTest.getText();
+ int num ,result;
+ result = 1;
+ num= Integer.valueOf(str);
+ for(int i=num;i>0;i--){
+ result = result*i;
+ }
+ str =String.valueOf(result);
+ inString = str;
+ storeString = str;
+ c.showingTest.setText(str);
+/**
+ * 要想实现让阶乘也加入混合运算中比较复杂;
+ * 我唯一想到的方法就是,阶乘操作之前必须有一个数
+ * 在按下阶乘的按钮之后将获取文本框内的字符串,对于当前字符串从后向前进行遍历
+ * 并且与正则表达式比较;
+ * 若扫到运算符,则停止并保留位置;把运算符之后的数字存入方法当中的局部变量
+ * 将其作为进行阶乘运算的数字
+ * 之后就是一个for循环输出结果到inString这个静态变量当中,以备用于之后的混合计算
+ * 这样就可以让阶乘算出来的中间结果不会显示出来的同时也可以进行混合运算。
+ * 但是这过于复杂,特别是遍历与比较的那一部分
+ * 于是我就大量简化了这一步
+ * 具体实现的过程是
+ * 输入数据->按下阶乘按钮->直接输出结果;
+ * 继续输入数字可以对于阶乘运算结果进行运算。
+ */
+ }
+ public class MyException extends Exception{
+ public MyException(){}
+ public MyException(String a){
+ c.showingTest.setText("0");
+ c.setStutas = false;
+ inString = "";
+ storeString = "";
+ JFrame window = new JFrame("报错");
+ window.setBounds(60,100,188,108);
+ window.add(new JTextField("输入有误,请重试"));
+ window.setResizable(false);
+ window.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
+ window.setVisible(true);
+ }
+ }
+
+
+}
+/**
+ * 表现符号,π
+
+ * log函数
+ * 阶乘函数
+ * 次方与开方
+ * 以及会车时地方法逻辑有问题
+ *“操作回车时是否为第一个字符”
+ */
+/*
+分为两层:
+inString存放用于计算的数据;
+storeString用于储存中间运算结果,
+用于M+,MC,MR,的显示与运算。
+ */
+/**
+ * 修改了程序逻辑,应该是能够顺利的完成M+,MC,MR,的运算,
+ * 以及在等号计算完能够直接输入运算符号以及
+ * 其他数字进行下一步运算:
+ * 例如,1+1结果为2,再次输入+3能够得到最终运算结果5.
+ * 加入了对于变量的必要的说明。
+ */
diff --git a/src/MyCalculator/MainClass.java b/src/MyCalculator/MainClass.java
new file mode 100644
index 0000000000000000000000000000000000000000..077c345ef89425532fbcc729f80ba0cee3bcf726
--- /dev/null
+++ b/src/MyCalculator/MainClass.java
@@ -0,0 +1,45 @@
+package MyCalculator;
+public class MainClass {
+ public static void main(String[] args) {
+ Calculator calculator = new Calculator();
+ calculator.setTitle("计算器");
+ }
+}
+/*
+对于本计算器,我希望能实现对于括号以及
+特殊符号的有关于优先级的运算;基于这种考虑,
+我将设计分为以下几部分:
+主程序:会写一些关于程序介绍
+计算器类:为了实现窗口以及组件的搭建。
+监视器类:对于窗口事件的处理,其中包含
+具体的输出文本的函数以及触发=的运算函数。
+stringOperation函数类:(对于最终字符串的处理)
+其中包含两个核心问题的解决:
+1.由正常输入的中缀表达式转变为后缀表达式的函数;
+2.处理后缀表达式计算出结果的函数。
+策略:先搭建窗口框架;
+创建监视器类并指向窗口(添加监视器);
+对结果的处理类,分为两大板块并最后去
+编写有关逆波兰算法的那一部分函数(需要参考)。
+ */
+
+/*
+要想做一个能实现基本四则运算的计算器其实也不会难,但是我一开始就认为一
+个计算器倘若不能去实现有关括号的那种稍微复杂的运算,那么这种计算器边无法实现开发者
+对于其辅助运算的目的,这就和一个人花脑筋去算又有什么区别;于是,我希望多做一点,尽量
+能实现关于括号的计算。但是在参阅过其他人的解决方法之后,我发现想要实现我的目的需要有
+关数据结构的知识但我在这一方面没有积累,不过为了能完成设计,我还是有针对必要的内容进
+行事先的学习。
+在有关输入符号与数字的处理方面:根据个人理解,首先要通过栈来实现逆波兰算法,将正常输
+入的中缀表达式转换为后缀表达式;之后需要编写一个方法,将后缀表达式以特定的顺序逐步计
+算出来,最后我还希望能够返回的结果是String类型。
+于是我认为string Operation类分为两个板块,应最后去处理有关逆波兰算法,并在参
+考有关其解决方案时,进行必要的修改。
+ */
+/*
+当然,这一部分代码还是很长的大概占整个程序的大概六分之一,
+为了能够体现我确实是去翻过有关资料,并且能学到一些新东西
+(最重要的还是希望老师手下留情,毕竟这是粘贴下来的)
+我将在该部分程序末尾,基于自己的理解,加上必要的注释。
+
+ */
\ No newline at end of file
diff --git a/src/MyCalculator/MyCalculator.iml b/src/MyCalculator/MyCalculator.iml
new file mode 100644
index 0000000000000000000000000000000000000000..d96c787fd3d2aad876232bef123433250e4251df
--- /dev/null
+++ b/src/MyCalculator/MyCalculator.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/MyCalculator/stringOperation.java b/src/MyCalculator/stringOperation.java
new file mode 100644
index 0000000000000000000000000000000000000000..3eea1ba093bdd9e520b49b3bd26cec252a1c586f
--- /dev/null
+++ b/src/MyCalculator/stringOperation.java
@@ -0,0 +1,225 @@
+package MyCalculator;
+import javax.swing.*;
+import java.util.*;
+import java.util.ArrayList;
+import java.util.Stack;
+import java.util.HashMap;
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
+import java.lang.Math.*;
+public class stringOperation {
+ private final Pattern p = Pattern.compile
+ ("(^-|(?<=\\D)-)?[\\d.]+|[+\\-*\\/%!()√^]|log");
+ //正则表达式,用于在预处理方法内匹配运算符与参数
+ private final HashMap operatorLevel = new HashMap();
+ //容器内存放运算符与其对应的优先级
+
+ private ArrayList eq1 = new ArrayList();
+ //存放运算式的列表
+ private ArrayList eq2 = new ArrayList();
+ //存放由中缀表达式转化得来的后缀表达式。
+ private Stack stk = new Stack();//用于存放运算符的栈。
+
+ stringOperation(){//初始化运算符及其优先级
+ operatorLevel.put("(", 0);
+ operatorLevel.put(")", 0);
+ operatorLevel.put("+", 1);
+ operatorLevel.put("-", 1);
+ operatorLevel.put("*", 2);
+ operatorLevel.put("/", 2);
+ operatorLevel.put("%", 2);
+ operatorLevel.put("^", 3);
+ operatorLevel.put("√", 4);
+ operatorLevel.put("log", 4);
+ }
+ /**
+ *
+ * 预处理方法,将运算符与相关的参数分开。
+ * 将运算参数提取出来保存为一个单独的字符串。
+ * 例:“1+1”变为“1”,“+”,“1”
+ */
+ private void pretreatment(String s){
+ Matcher m = p.matcher(s);//将输入的字符串对象s与正则表达式匹配。
+ while(m.find()){
+ eq1.add(m.group());//将其加入待处理容器ep1中,
+ // 并且保证参数以及运算符的顺序没有发生改变。
+ }
+ }
+
+ /**
+ * 正式的对于ep1处理,将ep1中的中缀表达式转换为后缀表达式,
+ * 转换结果存放在ep2当中。
+ * 例:1+2*3 转为 123*+
+ *
+ *
+ * ps.栈相当于一个不封顶的圆柱体
+ * 越早放入的物体将存放在越底层
+ * 要想拿到最底下的物体必须先把上层的物体拿出来
+ * 以下解释中,“最后放入栈中的数”其实意思就是上层的物体
+ * “从后到前”也是相当于从上层依次取出。
+ */
+ public void Infix2Postfix(){
+ for(int i=0;i operatorLevel.get(stk.peek())){//若该运算符的优先级大于栈中
+ // 最“后放入”的运算符的优先级,则能够将运算符直接放入stk栈中。
+ stk.push(c);
+ }
+ else{//倘若栈不为空,该运算符的优先级小于最“后放入”的运算符的优先级且不为左括号
+ while(!stk.empty() && !stk.peek().equals("(") && operatorLevel.get(stk.peek())>=operatorLevel.get(c)){
+ eq2.add(stk.pop());//那么将不断弹出运算符直到“最后的”运算符的优先级小于该运算符的优先级
+ }
+ stk.push(c);
+ }
+ }
+ else{//与第一个if对于,用于处理遍历ep1所找到的参数,
+ //若为参数将其直接加入ep2当中。
+ eq2.add(eq1.get(i));
+ }
+ }
+ //倘若在遍历完ep1所有字符串对象之后仍有运算符留在stk栈当中,
+ //则将其从“后”到“前”依次弹出,放入ep1直至没有字符串留在stk。
+ while(!stk.empty()){
+ eq2.add(stk.pop());
+ }
+
+ }
+ /*
+ 由于引用参考的内容输出的中间的转换表达式
+ 无法契合之后的后缀表达式处理方法,于是在
+ 中间加入了转换方法。将存放后缀表达式的ep2
+ 转为字符串数组形式
+ */
+ public static String []exchangeList(ArrayList t){
+ String[]newStr = new String[t.size()];
+ newStr = (String[]) t.toArray(newStr);
+ return newStr;//将存放后缀表达式的ep2转为字符串数组形式
+ }
+
+ /**
+ * 以下程序是对于后缀表达式处理的方法。
+ * 先进行对于ep2转换得来的字符串数组中的每一个对象进行遍历,
+ * 若是参数,则将其放入charactorList里面等待运算,
+ * 若为运算符,则取出charactorList内的一到两个数进行运算
+ * 最后将运算结果重新放入charactorList等待接下来的运算
+ * 直至剩下的仅有参数。
+ * 将参数转换成字符串形式然后返回。
+ * @param
+ * @return
+ */
+
+
+ public String operatePostfix(String[] str){
+ List charactorList = new ArrayList<>();
+ for(String c:str){
+ boolean isTrue = false;
+ for(int i=0;i=48&&c.charAt(i)<=57;//判断该字符串对象是否为参数
+ }
+ if(isTrue){
+ charactorList.add(Double.valueOf(c));//是的话将其放入 charactorList 等待运算
+ }
+ else{//不是的话就一定为运算符字符串,那么接下来
+ // 将进行对于charactorList内数据的提取,运算与重新压入
+ int size = charactorList.size();//存入最末尾参数的位置
+ switch (c){
+ case "+":
+ double num=charactorList.get(size-2)+charactorList.get(size-1);//提取
+ // 倒数第一以及倒数第二个参数,进行运算符的运算。
+ charactorList.remove(size-1);//减去已经参与运算的参数
+ charactorList.remove(size-2);//减去已经参与运算的参数
+ charactorList.add(num);//重新将结果压入容器
+ break;
+ case "-":
+ num=charactorList.get(size-2)-charactorList.get(size-1);
+ charactorList.remove(size-1);
+ charactorList.remove(size-2);
+ charactorList.add(num);
+ break;
+ case "*":
+ num=charactorList.get(size-2)*charactorList.get(size-1);
+ charactorList.remove(size-1);
+ charactorList.remove(size-2);
+ charactorList.add(num);
+ break;
+ case "/":
+ num=charactorList.get(size-2)/charactorList.get(size-1);
+ charactorList.remove(size-1);
+ charactorList.remove(size-2);
+ charactorList.add(num);
+ break;
+ case "^":
+ double num2= charactorList.get(size-2);
+ double num1= charactorList.get(size-1);
+ num=Math.pow(num2,num1);
+ charactorList.remove(size-1);
+ charactorList.remove(size-2);
+ charactorList.add(num);
+ break;
+ case "√"://单目运算符就只用提取一个数,运算之后将结果压入容器
+ num1= charactorList.get(size-1);
+ num=Math.sqrt(num1);
+ charactorList.remove(size-1);
+ charactorList.add(num);
+ break;
+ case "log":
+ num2= charactorList.get(size-2);
+ num1= charactorList.get(size-1);
+ num=logOperation(num1,num2);
+ charactorList.remove(size-1);
+ charactorList.remove(size-2);
+ charactorList.add(num);
+ break;
+
+ }
+ }
+
+ }
+ return String.valueOf(charactorList.get(0));//返回字符串
+ }
+
+ /**
+ * 每一次运算都需要将先前已经定义了的容器进行初始化,
+ * 也需要一个函数去调用前面编写的方法,
+ * @param str
+ * @return
+ */
+ public String mixedCalculation(String str){
+ eq1.clear();//初始化
+ eq2.clear();//初始化
+ while (!stk.empty()){//初始化
+ stk.pop();
+ }
+ pretreatment(str);//开始对于输入的字符串进行处理
+ Infix2Postfix();
+ String result = operatePostfix(exchangeList(eq2));
+ return result;//返回字符串形式的对象
+ }
+ /*StringBuffer str_result = new StringBuffer();
+ for(int i=0;i
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/out/production/java2022spring/.idea/.gitignore b/src/out/production/java2022spring/.idea/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..35410cacdc5e87f985c93a96520f5e11a5c822e4
--- /dev/null
+++ b/src/out/production/java2022spring/.idea/.gitignore
@@ -0,0 +1,8 @@
+# 默认忽略的文件
+/shelf/
+/workspace.xml
+# 基于编辑器的 HTTP 客户端请求
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/src/out/production/java2022spring/.idea/misc.xml b/src/out/production/java2022spring/.idea/misc.xml
new file mode 100644
index 0000000000000000000000000000000000000000..3d3ab27e979d39d5c546c323365ff06b8f343b4f
--- /dev/null
+++ b/src/out/production/java2022spring/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/out/production/java2022spring/.idea/modules.xml b/src/out/production/java2022spring/.idea/modules.xml
new file mode 100644
index 0000000000000000000000000000000000000000..ea25cb6475b9409a6cd5868ef50ea0cdc7ce9a84
--- /dev/null
+++ b/src/out/production/java2022spring/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/out/production/java2022spring/.idea/vcs.xml b/src/out/production/java2022spring/.idea/vcs.xml
new file mode 100644
index 0000000000000000000000000000000000000000..6c0b8635858dc7ad44b93df54b762707ce49eefc
--- /dev/null
+++ b/src/out/production/java2022spring/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/out/production/java2022spring/MyCalculator/.idea/misc.xml b/src/out/production/java2022spring/MyCalculator/.idea/misc.xml
new file mode 100644
index 0000000000000000000000000000000000000000..639900d13c6182e452e33a3bd638e70a0146c785
--- /dev/null
+++ b/src/out/production/java2022spring/MyCalculator/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/out/production/java2022spring/MyCalculator/.idea/modules.xml b/src/out/production/java2022spring/MyCalculator/.idea/modules.xml
new file mode 100644
index 0000000000000000000000000000000000000000..3718e39b616473557572df167390361cc80aff05
--- /dev/null
+++ b/src/out/production/java2022spring/MyCalculator/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/out/production/java2022spring/MyCalculator/.idea/vcs.xml b/src/out/production/java2022spring/MyCalculator/.idea/vcs.xml
new file mode 100644
index 0000000000000000000000000000000000000000..b2bdec2d71b6a5ce4ae49efc37516809c50e4d5e
--- /dev/null
+++ b/src/out/production/java2022spring/MyCalculator/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/out/production/java2022spring/MyCalculator/.idea/workspace.xml b/src/out/production/java2022spring/MyCalculator/.idea/workspace.xml
new file mode 100644
index 0000000000000000000000000000000000000000..4938aa9c28ef9d49a7c0322f85b6d5c935cca1c6
--- /dev/null
+++ b/src/out/production/java2022spring/MyCalculator/.idea/workspace.xml
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {
+ "keyToString": {
+ "RunOnceActivity.OpenProjectViewOnStart": "true",
+ "RunOnceActivity.ShowReadmeOnStart": "true",
+ "WebServerToolWindowFactoryState": "false"
+ }
+}
+
+
+
+
+ 1653317726539
+
+
+ 1653317726539
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/out/production/java2022spring/MyCalculator/Calculator.class b/src/out/production/java2022spring/MyCalculator/Calculator.class
new file mode 100644
index 0000000000000000000000000000000000000000..f5285f5c2cd5250d3c4aa6a1d713ed2e01fe4b7c
Binary files /dev/null and b/src/out/production/java2022spring/MyCalculator/Calculator.class differ
diff --git a/src/out/production/java2022spring/MyCalculator/CalculatorListener.class b/src/out/production/java2022spring/MyCalculator/CalculatorListener.class
new file mode 100644
index 0000000000000000000000000000000000000000..ae97dd137a3b4027f60a257e1be03fc96598d89a
Binary files /dev/null and b/src/out/production/java2022spring/MyCalculator/CalculatorListener.class differ
diff --git a/src/out/production/java2022spring/MyCalculator/MainClass.class b/src/out/production/java2022spring/MyCalculator/MainClass.class
new file mode 100644
index 0000000000000000000000000000000000000000..c3e8ca8750da1282e22cf0c8177d6a69a03a1c5b
Binary files /dev/null and b/src/out/production/java2022spring/MyCalculator/MainClass.class differ
diff --git a/src/out/production/java2022spring/MyCalculator/MyCalculator.iml b/src/out/production/java2022spring/MyCalculator/MyCalculator.iml
new file mode 100644
index 0000000000000000000000000000000000000000..d96c787fd3d2aad876232bef123433250e4251df
--- /dev/null
+++ b/src/out/production/java2022spring/MyCalculator/MyCalculator.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/out/production/java2022spring/MyCalculator/stringOperation.class b/src/out/production/java2022spring/MyCalculator/stringOperation.class
new file mode 100644
index 0000000000000000000000000000000000000000..bdae585661090c1b694b0f2539f435203621f0b5
Binary files /dev/null and b/src/out/production/java2022spring/MyCalculator/stringOperation.class differ
diff --git a/src/out/production/java2022spring/java2022spring.iml b/src/out/production/java2022spring/java2022spring.iml
new file mode 100644
index 0000000000000000000000000000000000000000..b107a2dd81165eaaf682ad3da030668b937fbb6c
--- /dev/null
+++ b/src/out/production/java2022spring/java2022spring.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/out/production/java2022spring/java2022spring/Test.class b/src/out/production/java2022spring/java2022spring/Test.class
new file mode 100644
index 0000000000000000000000000000000000000000..b5674a468b5ae1c1f323e527080ba64303f634c1
Binary files /dev/null and b/src/out/production/java2022spring/java2022spring/Test.class differ