软件工程结对作业02

本次作业的题目:

    在之前的四则运算基础上继续团队开发,详细要求如下:

    1. 生成的题目中计算过程不能产生负数,也就是说算术表达式中如果存在形如e1 − e2的子表达式,那么e1 ≥ e2。

    2、生成的题目中如果存在形如e1 ÷ e2的子表达式,那么其结果应是真分数。

    3、每道题目中出现的运算符个数不超过3个,括号不限。

    4、程序一次运行生成的题目不能重复,即任何两道题目不能通过有限次交换+和×左右的算术表达式变换为同一道题目。  

    5、把程序变成一个网页程序或智能手机程序, 用户通过设定参数,就可以得到各种题目,并可实现在线答题并评判。

设计思想:

     我们用的是基于MVC框架的开发,视图阶主要是是jsp页面,里面写了登陆界面,还有四则运算所需要的信息,以及用户作答界面,控制器阶主要处理来自jsp页面的的请求,模型里面我生成了一个实体类,与数据库的表项相对应,同时里面也写了一些操作数据库的函数。

本次实验UI没做感觉不是特别好

活动图:

源程序代码:

String[] str=new String[]{"+","-","*","/"};
    String[] str5=new String[100];
    int[] OperatorNum=new int[100];      
    int c=0;
    int num1,num2,num3,num4,num5;
    String str1,str2,str3,str4;
    num1=(int)(mn+Math.random()*(mx-mn+1));
    num2=(int)(mn+Math.random()*(mx-mn+1));
    num3=(int)(0+Math.random()*(3-0+1));
    str1=String.valueOf(num1);
    str2=String.valueOf(num2);
    str3=str1+str[num3]+str2;
    OperatorNum[c]=num3;
    c++;
    a=a-2;
    while(a!=0)
    {
        num4=(int)(0+Math.random()*(1-0+1));
        if(num4==0)
        {
            num5=(int)(0+Math.random()*(1-0+1));
            if(num5==0)
            {
                num3=(int)(0+Math.random()*(3-0+1));
                OperatorNum[c]=num3;
                c++;
                num1=(int)(mn+Math.random()*(mx-mn+1));
                str4=String.valueOf(num1);
                 if((num3==3)&&(OperatorNum[c-2]==3))
                 {
                     str3="("+str3+")"+str[num3]+str4;
                 }
                 else
                     str3=str3+str[num3]+str4;
            }
            else
            {
                num3=(int)(0+Math.random()*(3-0+1));
                OperatorNum[c]=num3;
                c++;
                num1=(int)(mn+Math.random()*(mx-mn+1));
                str4=String.valueOf(num1);
                str3="("+str3+")"+str[num3]+str4;
            }
        }
        else
        {
            num5=(int)(0+Math.random()*(1-0+1));
            if(num5==0)
            {
                num3=(int)(0+Math.random()*(3-0+1));
                OperatorNum[c]=num3;
                c++;
                num1=(int)(mn+Math.random()*(mx-mn+1));
                str4=String.valueOf(num1);
                 if((num3==3)&&(OperatorNum[c-2]==3))
                 {
                     str3=str4+str[num3]+"("+str3+")";
                 }
                 else
                     str3=str4+str[num3]+str3;
            }
            else
            {
                num3=(int)(0+Math.random()*(3-0+1));
                OperatorNum[c]=num3;
                c++;
                num1=(int)(mn+Math.random()*(mx-mn+1));
                str4=String.valueOf(num1);
                str3=str4+str[num3]+"("+str3+")";
            }
        }
        a--;
    }

运行结果截图:

 

编程总结:

 通过本次实验感觉自己不会的东西特别多,加油加油

PSP表格:

项目计划总结:

日期&&任务 听课 编写程序 阅读相关书籍 网上查找资料 日总计
周一 100 25 25 15 165
周二   30 35 25 90
周三   60 15 35 110
周四 100 30 30 25 185
周五   180   15 195
周六     60 15 75
周日     15   15
周总计 200 325 180 130 935

时间记录日志  

日期 开始时间 结束时间 中断时间 净时间 活动 备注
3/28 14:00 15:50 10 100 听课 软件工程上课
  17:10 17:20   10 阅读书籍 《构建之法》《梦断代码》
  21:00 21:25   20 网上查找资料  
3/29 14:00 15:00 10 110 结对编程 编写老师布置的作业
  16:00 17:00 10 110 看书 《构建之法》《梦断代码》
3/30 21:00 21:30   30 结对编程 编写老师布置的作业
4/1 14:00 15:50 10 100 听课 软件工程上课
4/2 16:00 18:00   120 结对编程 编写老师布置的作业
4/3 9:00 9:30   30 看书 《构建之法》《梦断代码》
4/4 9:00 9:30   30 看书 《构建之法》《梦断代码》

       

 小组成员:杨超群 http://www.cnblogs.com/linumy/ 

    

原文地址:https://www.cnblogs.com/GloryYT/p/5356935.html