20162307 结对编程第一周

第一周(2017-5-14 23:59截止)输出阶段总结博客

| PSP2.1 | Personal Software Process Stages | 预估耗时(分钟)| 实际耗时(分钟)|
| -------- | :----------------😐:----------------😐:---------------: |:-----😐
|Planning | 计划 | 20 |30 |
|Estimate |估计这个任务需要多少时间| 300 | 480 |
|Development |开发 | | |
|Analysis |需求分析 (包括学习新技术) | 20 |70 |
|Design Spec |生成设计文档 | | |
|Design Review |设计复审 (和同事审核设计文档) |20 | 20 |
|Coding Standard |代码规范 (为目前的开发制定合适的规范) | 0 | 0 |
|Design |具体设计 | 30 | 30 |
|Coding|具体编码 | 100 | 240 |
|Code Review |代码复审 | 60 | 90 |
|Test |测试(自我测试,修改代码,提交修改) | 60 | 100 |
|Reporting | 报告 | | |
|Test Report | 测试报告 | | |
|Size Measurement | 计算工作量 | 300 | 480 |
| Postmortem & Process Improvement Plan |事后总结, 并提出过程改进计划 | 30 | 30 |
| |合计| | 480 |

需求分析(描述自己对需求的理解,以及后续扩展的可能性)

1.随机生成题目数
2.整数运算
3.正确判题,如果错误,显示正确答案
4.统计正确率

设计思路(同时输出UML类图)

实现过程中的关键代码解释

  • 随机生成运算:

    public void setFormula() {
    this.a = (int) (Math.random () * 100);
    this.b = (int) (Math.random () * 100);
    switch ((int) (Math.random () * 4)) {
    case 0:
    op = '+';
    result = a + b;
    break;
    case 1:
    op = '-';
    result = a - b;
    break;
    case 2:
    op = '*';
    result = a * b;
    break;
    case 3:
    op = '/';
    while (this.b == 0) {
    this.b = (int) (Math.random () * 100);
    }
    if (a % b == 0)
    result = (a / b);
    else if (a % b != 0)
    result = (int)(a / b);
    System.out.printf ("%3.2f",result);
    }

  • 统计正确率及判题

    if((ex.resultanswer&&ex.result2.isInteger())||ex.result1answer1||ex.result2.equals(answer1)){
    correct_num++;
    System.out.println("正确,很棒啊,再接再厉");
    }
    else
    System.out.println("错啦,正确答案是:"+ex.result+" 继续加油哦");

    accuracy = (float)correct_num/num;

    System.out.printf("不错嘛,共%d题,做对%d题,正确率:%.2f,继续加油啊",num,correct_num,accuracy*100 );
    System.out.println('%');
    System.out.println("想要学的更好就输入你还想做的题目数,如果想休息了输入0");
    num=scan.nextInt();
    if(num==0) flag =0;

运行过程截图

代码托管地址

20162307

遇到的困难及解决方法

关于除法我们在测试中一直都在出错

  • 关于它的代码是

    case 3:
    op = '/';
    while (this.b == 0) {
    this.b = (int) (Math.random () * 100);
    }
    if (a % b == 0)
    result = (a / b);
    else if (a % b != 0)
    result = (int)(a / b);
    System.out.printf ("%3.2f",result);

  • a的值不是整数所以改进了代码

    result1 = (float) (a / c);

  • 分母不能为0,所以再次定义一个随机数c(在1至100之间)

    this.c = generator.nextInt(99)+1;

  • 改进之后的代码

    case 3:
    op = '/';
    if (a % c == 0)
    result = (a / c);
    else
    result = (int) (a/c);
    result1 = (float) (a / c);
    result2.setter ( a, c );
    result2 = result2.reduce_deno ( result2 );
    break;

对结对的小伙伴做出评

合作的很好,我们互相帮助,有了困难问题一起找解决方法,不停的实践、尝试,直到达到我们的要求
我们的水平有限,所以程序写的并不是很好,但是我们一直在改进,在测试.

结对小伙伴

posted @ 2017-05-14 13:43  张韵琪  阅读(210)  评论(10)    收藏  举报