四则运算--刘会芳

1.计划

   制作计划预估耗时20分钟,实际计划耗时40分钟

2.需求分析

 典型用户:

         家长:我希望做一个口算题卡软件,

                出一组题,提高孩子口算能力,

              以便节省我的时间。

         学生:我希望有一个口算题卡软件,

              随机出题,做题,提高我的口算能力

              以便可以随时查看我的错误题,纠错

3.用户故事

  任务一:出题,给一组他(10道)100以内的正整数加减算式

   任务二:答题,界面上显示10道题,选中,作答,完成,计时

   任务三:统计,对错界面,时间用是多少(秒),正确率

4.复审

   感谢同学帮我进行复审,发现我的一些不足之处,指出并及时做出改正。

5.具体设计

用例图:

 

6.核心代码

 

 1 package cn.edu.hnzj.springboot.entity;
 2 
 3 import java.util.*;
 4 
 5 public class GenQuestion {
 6     private String[] simple = {"+","-"};
 7     private String[] difficult = {"+","-","*","/"};
 8 
 9     public List<String> gen(Integer length,Integer max,boolean isDifficult){
10         String[] operators;
11         Random random = new Random();
12         String operator;
13         Integer pre;
14         Integer post;
15         HashSet<String> set = new HashSet<>();
16 
17         if (isDifficult){
18             operators = difficult;
19         } else {
20             operators = simple;
21         }
22 
23         while (set.size() < length){
24             pre = random.nextInt(max - 1) + 1;
25             operator = operators[random.nextInt(operators.length)];
26             if ("-".equals(operator)){
27                 post = random.nextInt(pre);
28             } else if ("/".equals(operator)){
29                 post = random.nextInt(max - 1) + 1;
30             } else {
31                 post = random.nextInt(max);
32             }
33             StringBuilder str = new StringBuilder("");
34             str.append(pre).append(operator).append(post);
35             set.add(str.toString());
36         }
37         List<String> list = Arrays.asList(set.toArray(new String[0]));
38 
39         return list;
40     }
41 }

 

 7.代码复审

8.测试 

9.测试报告

测试过程中出现多次失败,根据系统提示错误进行修改,可以正常运行

10.事后总结

一定要做好计划写代码前,耗时比计划的久。

11.PSP

posted @ 2021-05-31 18:20  __LHF  阅读(57)  评论(0)    收藏  举报