结对编程1-四则运算

结对编程1-四则运算
201421123098 胡丹丹 201421123118 张中结    
代码地址:https://git.coding.net/zzj201421123118/Second2.git

需求分析:

这个程序做成GUI(可以是Windows PC 上的,也可以是Mac、Linux,web,手机上的),成为一个有基本功能、一定价值的程序。在下面的功能需求中实现两个:

1.记录用户的对错总数,程序退出再启动的时候,能把以前的对错数量保存并在此基础上增量计算。
2.有计时功能,能显示用户开始答题后的消耗时间。
3.界面支持中文简体/中文繁体/英语,用户可以选择一种;

功能设计:

1.支持语言的切换

2.计时功能

3.错题收集

思维导图:

代码展示:

错题收集

FileWriter fw = null;

                    try {

                    //如果文件存在,则追加内容;如果文件不存在,则创建文件

                    File f=new File("D:/cuoti.txt");

                    fw = new FileWriter(f, true);

                    }

                    catch (IOException e) {

                    e.printStackTrace();

                    }

                    PrintWriter pw = new PrintWriter(fw);

                    pw.println(L8.getText()+"="+T3.getText()+"    "+"正确答案:"+sum1 +'\n');

                    pw.flush();

                    try {

                    fw.flush();

                    pw.close();

                    fw.close();

                    } catch (IOException e) {

                    e.printStackTrace();

                    }  
 B6.addActionListener(new ActionListener(){//错题本打开

            public void actionPerformed(ActionEvent d) {

                try

                {

                Runtime.getRuntime().exec("notepad.exe D:/cuoti.txt");

                }

                catch(Exception e)

                {

                System.out.println(e.getMessage());

                }

              }

            });

语言切换

        B3.addActionListener(new ActionListener(){//简体中文

            public void actionPerformed(ActionEvent e) {

                 L1.setText("题数:");

                 L2.setText("题目:");

                 L3.setText("输入答案:");

                 L4.setText("结果:");

                 L5.setText("答对题数:");

                 L6.setText("答错题数:");

                 L7.setText("答题时间:");

                 B0.setText("开始");

                 B1.setText("下一题");

                 B6.setText("错题集");

                //B2.setText("计时");

            }

        });

        B4.addActionListener(new ActionListener(){//繁体中文

            public void actionPerformed(ActionEvent e) {

                L1.setText("題數");

                L2.setText("題目:");

                 L3.setText("輸入答案:");

                 L4.setText("結果:");

                 L5.setText("答對題數:");

                 L6.setText("答錯題數:");

                 L7.setText("答題時間:");

                 B0.setText("開始");

                 B1.setText("下一題");

                 B6.setText("錯題集");

                

            }

        });

        B5.addActionListener(new ActionListener(){//英文

            public void actionPerformed(ActionEvent e) {

                 L1.setText("Question number");

                 L2.setText("Test:");

                 L3.setText("Enter the answer:");

                 L4.setText("Result:");

                 L5.setText("Right number:");

                 L6.setText("Wrong number:");

                 L7.setText("Answer times:");

                 B0.setText("Run");

                 B1.setText("Next");

                 B6.setText("WrongTest");

            

            }

        });

测试运行


PSP

PSP2.1 Personal Software Process Stages Time (%) Senior Student(/hour) Time (%)(/hour)
· Planning 计划 2 1.5
· Estimate 估计这个任务需要多少时间 0.5 0.5
· Analysis 需求分析 (包括学习新技术) 1 1
· Coding Standard 代码规范 0.5 0.5
· Design 具体设计 1.5 1
· Coding 具体编码 30 35
· Test 测试(自我测试,修改代码,提交修改) 1 1
Reporting 报告 1 1

小结

java编程最重要的思想就是面向对象,但此次编程虽然是用java写的,但还是惯于面向过程的思维,对面向对象的思想理解不够深,以至于许多功能能够在这次编程能够使用,但是代码不能复用,只创建了一个类,尝试过把各种功能分开,但是由于缺乏面向对象的思想,最终没有成功,与队友磨合的过程也是很曲折,从未合作编程过,这次也算一次深刻的体验。

posted @ 2017-03-15 10:42  丹hjk  阅读(169)  评论(2编辑  收藏  举报