201571030330 & 201571030307《小学四则运算练习软件》结对项目报告

源码在Github的仓库主页链接地址:https://github.com/ilyar1015/ArithmeticWeb

需求分析

设计开发一个小学生四则运算练习软件,使之具有以下功能:

1. 由计算机从题库文件中随机选择20道加减乘除混合算式,用户输入算式答案,程序检查答案是否正确,每道题正确计5分,错误不计分,20道题测试结束后给出测试总分;

2. 题库文件可采用实验二的方式自动生成,也可以手工编辑生成,文本格式如下:

3. 程序为用户提供三种进阶四则运算练习功能选择:百以内整数算式(必做)、带括号算式、真分数算式练习;

4. 程序允许用户进行多轮测试,提供用户多轮测试分数柱状图,示例如下:

5. 程序记录用户答题结果,当程序退出再启动的时候,可为用户显示最后一次测试的结果,并询问用户可否进行新一轮的测试;

6. 测试有计时功能,测试时动态显示用户开始答题后的消耗时间。

7. 程序人机交互界面是GUI界面(WEB页面、APP页面都可),界面支持中文简体(必做)/中文繁体/英语,用户可以进行语种选择。

软件设计

使用类图:

 

核心代码:

   随机出题:

  

package com.arithmetic.question;
import java.util.ArrayList;

public class SetAQuestion {
    int n;
    int next,time;
    String topic;
    GetRandomDigit grd=null;
    ArrayList<Topic> al;
    Topic question;
    ArithmeticResult ar;
    public SetAQuestion(int n){
        this.n=n;
        init();
        setQuestion();
    }
    
    
    private void init(){
        grd=new GetRandomDigit();
        al=new ArrayList<Topic>();
        ar=new ArithmeticResult();
    }
    
    private void setQuestion(){
        //出题的数量
        int[] questionTopic;;
        int[] questionOprator;
        for(int i=0;i<n;i++){
            //出题的长度
            time=grd.Time();
            questionTopic=new int[time];
            questionOprator=new int[time-1];
            for(int t=0;t<time;t++){
                questionTopic[t]=grd.randomDigit();
                if(t<time-1){
                    questionOprator[t]=grd.oprator();
                }
            }
            topic="";
            int bracketsIndex=-1;
            if(PQ()){
                bracketsIndex=grd.BracketsIndex(time);
            }
            for(int t=0;t<time;t++){
                if(bracketsIndex==t){
                    topic=topic+"(";
                }
                
                topic=topic+questionTopic[t];
                if(bracketsIndex+1==t && bracketsIndex!=-1){
                    topic=topic+")";
                }
                if(t<time-1){
                    topic=topic+getType(questionOprator[t]);
                }
            }
            topic=topic+"=";
            double a=ar.Result(topic);
            if(a<0||a%1!=0||a>500){
                i--;
                continue;
            }
            question=new Topic(topic,(int)a);
            al.add(question);
        }
    }
    
    private String getType(int type){
        if(type==1){
            return "+";
        }else if(type==2){
            return "-";
        }else if(type==3){
            return "×";
        }else{
            return "÷";
        }
    }
    
    private boolean PQ(){
        int PQ=grd.probabilityQuestion();
        if(PQ<=120){
            return true;
        }else{
            return false;
        }
    }
    
    public ArrayList<Topic> getQuestion(){
        return al;
    }
}

  

   将题目以JSON的方式放到HTML页面

    

package com.arithmetic.question;
import java.io.IOException;
import java.util.ArrayList;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.bind.ParseConversionEvent;

import net.sf.json.JSONArray;
public class GuestionToHtml extends HttpServlet{
    private static final long serialVersionUID = 1L;
    private ArrayList<Topic> al=null;
    SetAQuestion sqt=null;
    ListToJson ltj;
    int textTime=1;
    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        //设置编码
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        //设置返回文本的类型
        response.setContentType("text/json");
        String Ttimes=request.getParameter("n");
        textTime=Integer.valueOf(Ttimes);
        initTest();
        String jsonString=toJson();
        System.out.println(jsonString);
        response.getWriter().print(jsonString);
                
        
    }
    private void initTest(){
        al=new ArrayList<Topic>();
        sqt=new SetAQuestion(textTime);
        ltj=new ListToJson();
    }
    
    private String toJson(){
        al=sqt.getQuestion();
//        String JSON="{"topic0":"+"""+al.get(0).getTopic()+"","result0":"+"""+al.get(0).getResult()+""";
//        for(int i=1;i<al.size();i++){
//            JSON=JSON+","topic"+i+"":""+al.get(i).getTopic()+"","result"+i+"":""+al.get(0).getResult()+""";
//        }
        JSONArray JSON=ltj.LTJ(al);
        return JSON.toString();
    }
}

  验证登录

    

package com.arithmetic.sql;

import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/Login")
public class Logined extends HttpServlet {
    private static final long serialVersionUID = 1L;
    LinkSql ls;
    String jsonString;
    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        //设置编码
        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        //设置返回文本的类型
        response.setContentType("text/json");
        initTest();
        
        String name=request.getParameter("name");
        String password=request.getParameter("password");
        System.out.println(name+" ++ "+password);
        if(logined(name,password)){
            jsonString="{"massage":true}";
        }else{
            jsonString="{"massage":false}";
        }
        System.out.println(jsonString);
        response.getWriter().print(jsonString);
                
        
    }
    
    private void initTest(){
        ls=new LinkSql();
    }
    
    private boolean logined(String name,String password){
        ResultSet rs=ls.selectSqlDate(String.format("select * from user where name='%s'", name));
        try {
            while(rs.next()){
                if(rs.getString("name").equals(name)&&rs.getString("password").equals(password)){
                    return true;
                }else{
                    return false;
                }
            }
            
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return false;
    }
}

  出题见面 ajax 

    

var res;
function getQuestion(){
    var questionTime=$('#questionTime').val();
    $.ajax({
        type:"GET",
        url:"GuestionToHtml",
        data:"n="+questionTime,
        datatype:"text/json",
        success:function(result){
            $("#result").attr({ disabled: "value" });
            res=result;
            $('#question').text("");
            for(var i=0;i<result.length;i++){
                if(i%2==0){
                    $('#question').append('<li class="list-group-item col-md-6 fl" style="height: 50px;">'
                            +'<div class="form-group fl">'
                            +'<label for="inputEmail3" class="col-sm-4 control-label" style="margin-top: 5px;">'+result[i].topic+'</label>'
                            +'<div class="col-sm-1">'
                            +'<input type="number" style=" 100px;" class="form-control"  '+'id="'+'q'+i+'"'+'  placeholder="答案">'
                            +'</div>'
                            +'</div>'
                            +'</li>');  
                }else{
                    $('#question').append('<li class="list-group-item col-md-6 fr" style="height: 50px;">'
                            +'<div class="form-group fl">'
                            +'<label for="inputEmail3" class="col-sm-4 control-label" style="margin-top: 5px;">'+result[i].topic+'</label>'
                            +'<div class="col-sm-1">'
                            +'<input type="number" style=" 100px;" class="form-control"  '+'id="'+'q'+i+'"'+'  placeholder="答案">'
                            +'</div>'
                            +'</div>'
                            +'</li>'); 
                }
                
            }
        },
        error:function(result){
            alert("服务器出现异常");
        }
    });
    
}

各模块界面:

登录:

 答题:

 

统计结果:

 

学生注册:

 

e.描述结对的过程,提供两人在讨论、细化和编程时的结对照片(非摆拍)。

         由于我们采用的是分工合作的方法完成项目,彼此不熟悉彼此的代码风格,两个人也没有花时间去磨合,只是完成一个简单的初期想法就开始各自做代码。在这期间,队友给我带来了很多的新思路,但同时呢,也出现过两个人彼此误导,在长时间编程以后两个人都陷入了错误之中。两个人也都在磨合之中,逐渐提高了Java的编程能力。

 

 

 

f.提供此次结对作业的PSP。

PSP2.1

任务内容

计划共完成需要的时间(min)

实际完成需要的时间(min)

Planning

计划

8

6

·       Estimate

·  估计这个任务需要多少时间,并规划大致工作步骤

8

6

Development

开发

200

407

··       Analysis

  需求分析 (包括学习新技术)

6

10

·       Design Spec

·  生成设计文档

5

6

·       Design Review

·  设计复审 (和同事审核设计文档)

4

6

·       Coding Standard

  代码规范 (为目前的开发制定合适的规范)

3

3

·       Design

  具体设计

10

12

·       Coding

  具体编码

100

200

·       Code Review

·  代码复审

7

10

·       Test

·  测试(自我测试,修改代码,提交修改)

13

60

Reporting

报告

9

6

··       Test Report

·  测试报告

3

2

·       Size Measurement

  计算工作量

2

1

·       Postmortem & Process Improvement Plan

·  事后总结 ,并提出过程改进计划

3

3

g. 请使用汉堡评价法给你的小伙伴一些点评。

       队友思路很清晰,效率也很高。在两个人的思想碰撞中,发现自己好多的不足,一起完成项目的过程各种想法的碰撞,并且让在合作的过程当中体会到了个人项目好多的不同。希望在未来还有机会可以一起合作。

h. 结对编程真的能够带来1+1>2的效果吗?通过这次结对编程,请谈谈你的感受和体会。

          通过这次结对编程 我觉得结对编程真的能够带来1+1>2的效果,在前期两个人一起讨论对于需求分析,功能分析这些方面,比起一个人要好得多,很多想不到的地方队友会想到,两个人能够很好的互补,比起一个人的代码编写,两个人写代码的过程少了无趣。,要比一个人闷头写程序改bug要有趣的多,工作效率也相对来说会高一点;其次对于编程能力相对较弱的我来说,1+1>2的效果最大的体现就是我能从对方身上学到很多我之前运用不熟练或者根本不知道的新知识,这对我之后的学习起到了很积极的作用 ,两个人一起做代码遇到BUG,就不会一个人那样一顿猛查,然后就是各种修改,当发现还是如此的时候,基本也就放弃了,等着一会在看,就去做其他的是。但有了队友,自己遇到BUG,队友会帮忙修改,BUG 也就不是那么恐怖了。以上就是我的想法 。

 

原文地址:https://www.cnblogs.com/iguodong/p/8719428.html