组员:201421123015 陈麟凤 201421123019 张志杰 201421123020 黄海鸿
coding 地址 :https://coding.net/u/zhang1995/p/worktwo/git/tree/master/
需求分析:
1、除了整数的四则运算还要支持分数的四则运算;
2、运算符为 +, −, ×, ÷;
3、能处理用户的输入,包括分数;
4、程序基于GUI界面;
5、能记录用户做题的对错数量,下次使用程序时能在之前的数量上增加;
6、有计时功能,能显示用户开始答题后的消耗时间
7、界面支持中文简体/中文繁体/英文,用户选择一种
思维导图:
功能实现:
主要功能除了在第一次作业中的四则运算功能,增加了计时器功能、语言选择功能以及记录对错题总数的功能;
代码展示:
计时器:
now.setHours(0); now.setMinutes(0); now.setSeconds(0); final Timer timer = new Timer(1000, new ActionListener() { public void actionPerformed(ActionEvent e) { Date now2 = new Date(now.getTime() + 1000); now = now2; SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss"); lbl.setText(formatter.format(now)); } }); timer.start();
语言选择的部分代码:
mi1表示中文简体;mi2表示中文繁体;mi3表示英文;
mi1.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { jlb.setText("请输入生成的题目数量:"); jtf.getText(); jb.setText("生成題目"); } }); mi2.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { jlb.setText("請輸入生成的題目數量:"); jtf.getText(); jb.setText("生成題目"); } }); mi3.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { jlb.setText("please input the number of questions you want:"); jtf.getText(); jb.setText("generate tests"); } });
对错题数目存入文件:
jbt.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { File file = new File("D:/newfile.txt"); String line =null; try { BufferedReader br = new BufferedReader(new FileReader(file)); try { while((line = br.readLine()) != null){ String[] num = line.split("#"); zheng1=Integer.parseInt(num[1]); cuo1=Integer.parseInt(num[3]); }} catch (IOException ex) { Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex); } } catch (FileNotFoundException ex) { keep(); } keep(); } private void keep() { FileOutputStream fop = null; File file; String content = "正确#"+(n-MainFrame.cuowu+zheng1)+"#错误#"+(MainFrame.cuowu+cuo1)+"#"; try { file = new File("D:/newfile.txt"); fop = new FileOutputStream(file); if (!file.exists()) { file.createNewFile(); } byte[] contentInBytes = content.getBytes(); fop.write(contentInBytes); fop.flush(); fop.close(); } catch (IOException e) { e.printStackTrace(); } finally { try { if (fop != null) { fop.close(); } } catch (IOException e) { e.printStackTrace(); } } } });
测试运行:
本次实验合作照片:
PSP:
PSP2.1 | Personal Software Process Stages | Time(min) Senior Student | Time (min) |
Planning | 计划 | 5 | 2 |
Estimate | 估计这个任务需要多少时间 | 4 | 10 |
Development | 开发 | 3 | 0 |
Analysis | 需求分析 (包括学习新技术) | 3 | 5 |
·Design Spec | 生成设计文档 | 1 | 0 |
·Design Review | 设计复审 | 1 | 0 |
Coding Standard | 代码规范 | 10 | 5 |
· Design | 具体设计 | 5 | 5 |
Coding | 具体编码 | 60 | 250 |
·Code Review | 代码复审 | 5 | 60 |
Test | 测试(自我测试,修改代码,提交修改) | 10 | 5 |
Reporting | 报告 | 6 | 3 |
测试报告 | 3 | 1 | |
计算工作量 | 4 | 6 | |
并提出过程改进计划 | 5 | 0 |
小结:本次作业由我与黄海鸿同学一起,与陈麟凤同学一起完成的,在语言定义以及文本输出控制的程序片段中发生很多问题,在不断的讨论以及在网络中寻找解决方法后终于是将代码给写出来。可以说是花费了很多心力。不同于自己写代码,在帮助陈麟凤同学时,发现了自己的想法与他人的想法并不一定能够很好的结合,所以花费了很多的时间在沟通上。
汉堡包式评价:
再把肉放上: 在这次编程中出现不少问题,不仅有技术上的更有在交流中发生的争执,与黄海鸿同学发生争执后在陈麟凤同学的劝说下一起重新合作。也侧面体现了交流的重要性。更多时候应该是把想法说出来让同学试着接受而不是硬要使用自己的方法,那样只会让时间流逝而无所成。
再来一片面包:结对编程中有领航员跟驾驶员的关系无疑能对工作的顺利进行起到非常大的作用,可以取长补短极大提高项目的进程,而最重要的是可以增加队友间的感情,使往后的配合更加默契。希望能在下次合作中做得更好。