软工网络15结对编程练习

 

一.结对编程成员:

叶金蕾(201521123085):http://www.cnblogs.com/yeei66/

张文博(201521123089):http://www.cnblogs.com/Abe1/

二.对原有程序分析:

选择博客:http://www.cnblogs.com/shizhuangde/p/6552441.html  代码https://coding.net/u/lhl1212/p/ArithmeticTest/git?public=true

 

百度脑图

 

 

三.改进现有代码:

 

我们发现当我们第一次运行程序的时候,计算出来的正确率结果是正确的,然后点击“继续”之后,他的正确题数rn会累加,导致正确率计算出错,所以,我们应该在显示正确率之后令“rn=0.0”,避免他的累加

四.代码展示:

语言:

public void setLanguage() {
        String[] choiceLanguage = { "简体中文", "繁体中文", "English" };
        String language = (String) JOptionPane.showInputDialog(null, "请选择语言:\n", "Choice a language for client",
                JOptionPane.PLAIN_MESSAGE, new ImageIcon("icon.png"), choiceLanguage, "简体中文");
        if (language == null) {
            System.exit(-1);
        } else {
            try {
                reader = new BufferedReader(new FileReader(new File("language/" + language + ".txt")));
                String s;
                while ((s = reader.readLine()) != null) {
                    tips.add(s);
                }
                reader.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

 

运算:

 private void DivideButtonActionPerformed(java.awt.event.ActionEvent evt) {                                             
        operateCommand = "/";
        op1 = Double.parseDouble(resultText.getText());
        //System.out.println("op1="+op1);
        firstDigit = true;
    }                                            

    private void MultiplyButtonActionPerformed(java.awt.event.ActionEvent evt) {                                               
        operateCommand = "*";
        op1 = Double.parseDouble(resultText.getText());
        firstDigit = true;
    }                                              

    private void SubtractButtonActionPerformed(java.awt.event.ActionEvent evt) {                                               
        operateCommand = "-";
        op1 = Double.parseDouble(resultText.getText());
        firstDigit = true;
    }                                              

    private void AddButtonActionPerformed(java.awt.event.ActionEvent evt) {                                          
        operateCommand = "+";
        op1 = Double.parseDouble(resultText.getText());
        firstDigit = true;
    }        

 

 

 

 

五.PSP:

 

posted @ 2018-03-25 18:03  Abe1  阅读(231)  评论(1编辑  收藏  举报