20194669 automatically generates four arithmetic problem first edition report

First, the needs analysis

Parents and teachers in order to allow the children to do some exercises in the winter and summer, and enhance the child's computing power. At the same time teaching in the classroom but also reduce the burden on teachers, so students set out to develop this program topic.

Second, the functional design

1, the basic functions:

(1)自动生成10道100以内的2个操作数的四则运算算式    
(2)(+ -  */)符号可随机生成
(3)运算结果也在100以内

2, extensions

(1)可以自动剔除重复算式
(2)出题题目数量可根据用户情况定制
(3)可以选择是否包含乘法和除法
(4)操作数数值范围可控性(如操作数 在100以内,还是1000以内)
(5)用户选择是否允许出现负数
(6)可以选择生成的运算题存储到电脑中

Third, the design and implementation

1, and language versions

(1)java语言,版本jdk1.8.0

2, development tools

(1)eclipse
(2)Notepad++

3, action type and use

(1)Scanner类:用于用户输入输出(2)Random类:用于随机生成数(3)FileWriter类:用于存储文件

4, an important function

(1)inputNumber函数:将要输入的出题个数
(2)oppNumber函数:是否存在乘除计算题
(3)selectNumber函数:选择题目的操作数的范围(100、1000)
(4)isNegative函数:是否存在负数
(5)isSave函数:是否存到电脑内
(6)MENU函数:菜单

Fourth, the test run

V. code snippet shows

public void opptt(int n, int oppn, int sel, boolean flag, boolean ifSave) {
        for (int i = 0; i < n; i++) {
            num1 = r.nextInt(sel) + 1;
            opp = r.nextInt(oppn);
            switch(opp){
            case 0:
                num2 = r.nextInt(sel - num1);
                break;
            case 1:
                num2 = r.nextInt(num1);
                break;
            case 2:
                num2 = r.nextInt(sel / num1);
                break;
            case 3:
                num2 = r.nextInt(num1);
                break;
            }

            if (flag) {
                int f = r.nextInt(2);
                int p = r.nextInt(2);
                if (0 == f)
                    num1 = -num1;
                if (0 == p)
                    num2 = -num2;
            }
            if (num1 < 0)
                str1 = "(" + num1 + ")";
            else
                str1 = "" + num1;
            if (num2 < 0)
                str2 = "(" + num2 + ")";
            else
                str2 = "" + num2;
            if (ifSave) {
                w.append(str1 + "" + oppt[opp] + str2 + "=" + "   ");

                try {
                    FileWriter fw = new FileWriter("d:/result.txt");
                    fw.write(w.toString());
                    fw.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            System.out.println(str1 + "" + oppt[opp] + str2 + "=");
        }
        
    }
    public int inputNumber() {  // 将要输入的出题个数
        int n;
        n = S.nextInt();
        return n;
    }

    public int oppNumber() {// 是否存在乘除计算题
        int oppn;
        oppn = S.nextInt();
        if (1 == oppn)
            return 4;
        else
            return 2;
    }
    public int selectNumber() {// 选择题目的操作数的范围(100或1000)
        int sel;
        sel = S.nextInt();
        if (1 == sel)
            return 101;
        else
            return 1001;
    }

VI Summary

本程序代码主要包含以下几个模块:
(1)inputNumber函数:将要输入的出题个数
(2)oppNumber函数:是否存在乘除计算题
(3)selectNumber函数:选择题目的操作数的范围(100、1000)
(4)isNegative函数:是否存在负数
(5)isSave函数:是否存到电脑内
(6)MENU函数:菜单
    在java语言中有强大的封装,允许一个组件声明它的公有类型(public)中,哪些可以被其他组件访问,哪些不可以。
这些特性将有益于应用的开发者、类库的开发者和java se平台直接的或者间接地实现者。它可以使系统更加健壮,并且可以提高他们的性能。
    本程序各个模块互相影响,也互相调用。

Seven, PSP

PSP Estimated time real time
plan 1 2
demand analysis 0.5 1
Generate design documents 0.5 1
Code Specification 0.5 0.5
Specific design 1 2
Specific coding 2 5
Code Review 1 2
test 1 2
to sum up 1 1
Total time spent 8.5 16.5

Guess you like

Origin www.cnblogs.com/hou520/p/11536256.html