《个人软件开发流程》——申同燕
1.需求分析:
根据用户输入的题目个数,产生含有2个数字,1种运算符的题目,并显示出来。
2.核心代码:
package entity; import java.util.ArrayList; import java.util.Random; import java.util.Scanner; import java.util.ArrayList; import java.util.List; import java.util.Random; import java.util.function.BiFunction; /** * 试卷实体类 */ public class Exam { private List<Subject> subjectList; public List<Subject> getSubjectList() { return subjectList; } public void setSubjectList(List<Subject> subjectList) { this.subjectList = subjectList; } public Exam() { System.out.println("请输入要生成几道题目:"); Scanner sc = new Scanner(System.in); int count = sc.nextInt(); List<Subject> list = new ArrayList<Subject>(); BiFunction<Integer, Integer, Integer> add = (x, y) -> x + y; BiFunction<Integer, Integer, Integer> minus = (x, y) -> x - y; BiFunction<Integer, Integer, Integer> multiple = (x, y) -> x * y; BiFunction<Integer, Integer, Integer> divide = (x, y) -> x / y; for (int i = 0; i < count; i++) { Subject subject = new Subject(); Integer a = new Random().nextInt(99); Integer b = new Random().nextInt(99); subject.setA(a); subject.setB(b); subject.setIndex(i + 1); Integer symbol = new Random().nextInt(3); if (symbol == 0) { subject.setSymbol("+"); subject.setAnswer(add.apply(a, b)); } else if (symbol == 1) { subject.setSymbol("-"); subject.setAnswer(minus.apply(a, b)); } else if (symbol == 2) { subject.setSymbol("×"); subject.setAnswer(multiple.apply(a, b)); } else if (symbol == 3) { subject.setSymbol("÷"); subject.setAnswer(divide.apply(a, b)); } list.add(subject); } this.subjectList = list; } public static void main(String[] args) { Exam exam = new Exam();// 随机出题 // 查看试卷 exam.getSubjectList().forEach(subject -> { System.out.println("第" + subject.getIndex() + "题:" + subject.getA() + " " + subject.getSymbol() + " " + subject.getB() +"="); }); System.out.println("输出你的答案,每题答案之间用空格分开:"); System.out.println(); Scanner sc = new Scanner(System.in); int count = sc.nextInt(); System.out.println("-----------*答案为*----------"); exam.getSubjectList().forEach(subject -> { System.out.println("第" + subject.getIndex() + "题答案:"+ subject.getAnswer()); }); } } /** * 定义题目的类 * */ class Subject { private Integer index; private Integer a; private Integer b; private String symbol; private Integer answer; public Integer getIndex() { return index; } public void setIndex(Integer index) { this.index = index; } public Integer getA() { return a; } public void setA(Integer a) { this.a = a; } public Integer getB() { return b; } public void setB(Integer b) { this.b = b; } public String getSymbol() { return symbol; } public void setSymbol(String symbol) { this.symbol = symbol; } public Integer getAnswer() { return answer; } public void setAnswer(Integer answer) { this.answer = answer; } }
3.PSP对照表
PSP |
任务内容 |
计划共完成需要的时间(min) |
实际完成需要的时间(min)
|
Planning |
计划 |
25 |
30 |
Estimate |
· 估计这个任务需要多少时间,并规划大致工作步骤 |
25 |
30 |
Development |
开发 |
248 |
323 |
·Analysis |
·分析需求 |
15 |
20 |
·Design Spec |
·生成设计文档 |
20 |
25 |
·Design Review |
·设计复审 |
8 |
10 |
·Coding Standard |
·代码规范 |
5 |
3 |
·Design |
·具体设计 |
25 |
30 |
·Coding |
·具体编码 |
120 |
160 |
·Code Review |
·代码复审 |
30 |
45 |
·Test |
·测试 |
25 |
30 |
Record Time Spent |
记录用时 |
27 |
31 |
Test Report |
测试报告 |
15 |
17 |
Size Measurement |
计算工作量 |
7 |
8 |
Postmorterm |
事后总结 |
5 |
6 |
4.总结
具体编码与代码复审较为费时间,许多方法都忘记了,具体编码环节估计和实践差距太大了。总体来说,磕磕绊绊写完了。还是要多加练习。