个人作业
一、预估与实际
| > | PSP2.1 | Personal Software Process Stages | 预估耗时(分钟) | 
|---|---|---|---|
| Planning | 计划 | 695 | 860 | 
| ? Estimate | ? 估计这个任务需要多少时间 | 695 | 860 | 
| Development | 开发 | 695 | 860 | 
| ? Analysis | ? 需求分析 (包括学习新技术) | 120 | 140 | 
| ? Design Spec | ? 生成设计文档 | 20 | 30 | 
| ? Design Review | ? 设计复审 | 30 | 40 | 
| ? Coding Standard | ? 代码规范 (为目前的开发制定合适的规范) | 30 | 40 | 
| ? Design | ? 具体设计 | 80 | 100 | 
| ? Coding | ? 具体编码 | 270 | 310 | 
| ? Code Review | ? 代码复审 | 30 | 40 | 
| ? Test | ? 测试(自我测试,修改代码,提交修改) | 35 | 45 | 
| Reporting | 报告 | 25 | 35 | 
| ? Test Repor | ? 测试报告 | 20 | 25 | 
| ? Size Measurement | ? 计算工作量 | 15 | 25 | 
| ? Postmortem & Process Improvement Plan | ? 事后总结, 并提出过程改进计划 | 20 | 30 | 
| 合计 | 860 | 
二、需求分析
我通过百度和朋友的方式了解到,小学一、二年级数学有如下的几个特点:
用户输入的参数,需要判断是否符合要求,不符合就直接结束运算,符合就继续判断。
根据输入的参数,随机生成加减乘除运算,运算需要符合小学一二年级的算术规则,
加法不能大于100,减法不能小于0,乘除不能为0,最后要有文件的生成与写入。
写出具体实现的步骤
如果数组越界,就扩大数组;
无法用命令行直接传参,用args数组解决;
ArrayList集合中变量都为String类型,int类型的变量需要先强制转换成String类型。
>public static void h(ArrayList<String> list) { // 新建一个方法用来专门输出
        int i = 0;
        File toFile = new File("out.txt");
        PrintStream ps = null;
        OutputStream os = null;
        try {
            // ps=new PrintStream(toFile);//可直接传File
            os = new FileOutputStream(toFile, false);// true在原文件上追加
            ps = new PrintStream(os, true);// true自动刷新
            for (i = 0; i <= 2*n- 2; i = i + 2) {
                ps.println(list.get(i));
            }
            ps.println();
            for (i = 0; i <= 2*n - 2; i = i + 2) {
                ps.print(list.get(i));
                ps.println(list.get(i + 1));
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } finally {
            ps.close();
        }
}
创建out.text文件,把题目和答案存入txt文件中。原文:https://www.cnblogs.com/chenbin1234/p/9631822.html