• 软件工程网络15结对编程作业(201521123103 吴雅娟)


    一、成员信息

    吴雅娟:201521123103 (http://www.cnblogs.com/yayaya/)
    赵铭:201521123093 (http://www.cnblogs.com/zhaoMing3/)
    结对码云地址: (https://gitee.com/pair_programming/daima/tree/master)
    所选代码:个人博客地址5:(http://www.cnblogs.com/NianQiFeng) 源代码:(https://git.coding.net/qwx_hh/java-szys.git)

    二、需求分析

    • 功能:
      • 可以选择题目语言
      • 随机生成题目,实现基本的加减乘除四则运算
      • 做完题目回车可以查看答案是否正确
      • 计时器功能,点击开始计时时,能显示用户开始答题后的消耗时间
      • 对自己的错题进行复习
    • 问题:
      • 计时的地方可以手动输入时间,然后计时就结束了
      • 语言选择模糊,没有按钮显示

    三、程序设计

    1、修改前代码的覆盖率 具体文件我放在了码云里


    2、修改后的代码覆盖率具体文件我放在了码云里


    3、功能图

    四、修改代码展示

    1、界面修改

       public List<JTextField> Field_list=new ArrayList<JTextField>();
        public Frame() {
            super("Myapp");
            hs.History_create();
            initComponents();
            if(Test_Number.l==1){
            	Set_qusetion.setText("开始");
            	jLabel2.setText("计时:");
            	jLabel1.setText("正确率:");
            	jLabel3.setText("用时:");
            	Review.setText("复习");
            	jLabel4.setText("正确:");
            	jLabel6.setText("全部:");
            }
            if(Test_Number.l==2){
            	Set_qusetion.setText("Start");
            	jLabel2.setText("Timing:");
            	jLabel1.setText("Correct rate:");
            	jLabel3.setText("Time cost:");
            	Review.setText("Review");
            	jLabel4.setText("Right:");
            	jLabel6.setText("All:");
            }
            jLabel7.setText(""+hs.total);
            jLabel5.setText(""+hs.right_number);
        }
    

    2、增加运算符

    public String int_operation()   //整数计算
        {
            int result = 0;
            if(a==0)
                result=f+g;
            if(a==1)
                result=f-g;
            if(a==2)
                result=f*g;
            astr = String.valueOf( result);
            if(a==3)
            {
                if(g==0)
                {
                    astr=int_operation();
                    return astr;
                }
                else
                {
                    if(g!=0&&g!=1){
                        int d=common_divisor(f,g);  //公约数计算函数
                        f=f/d;
                        g=g/d;
                        astr = (f+"/"+g);
                    }
                    if(g==1)
                        astr=(""+f);
                }
            }
            if(a==4)   //新加的
            {
            	if(m==0){    //m==0时是减法
            		result=(f-g)*n;  
            	}
            	if(m==1){
            		result=(f+g)*n;  //m==1时是加法
            	}
            }
            return astr;
        }
        public String fra_operation(){     //分数计算
            this.compute11 = new Random().nextInt(10)%(10-1+1) + 1;
            this.compute21 = new Random().nextInt(10)%(10-2+1) + 2;
            this.compute31 = new Random().nextInt(10)%(10-1+1) + 1;
            this.compute41 = new Random().nextInt(10)%(10-2+1) + 2;
            if(compute31<compute21||compute41<compute31||compute21%compute11==0||compute41%compute31==0)
            {
                astr=fra_operation();
                return astr;
            }       
            int fz=1,fm=compute21*compute41; //fz==分子,fm==分母
            if(a==0)
                fz=compute21*compute41+compute21*compute31;
            if(a==1){
                fz=compute11*compute41-compute21*compute31;
                if(fz==0)
                {
                    return astr=("0");
                }
            }
                
            if(a==2)
                fz=compute11*compute31;
            if(a==3)
            {
                fz=compute11*compute41;
                fm=compute21*compute31;
            }
            int f=common_divisor(fm,fz);
            if(f>0){
                fm=fm/f;
                fz=fz/f;
            }
            if(f<0){
                fm=-fm/f;
                fz=-fz/f;
            }
            astr = (fz+"/"+fm);
    //        if(astr.equals("1/1")) astr="1";
    //        if(fm==1)
    //        {
    //        	astr=(fz+"");
    //        }
            return astr;
        }
        public static int common_divisor(int m,int n)
        {
            while(m%n!=0){
                int t=m%n;
                m=n;
                n=t;
            }
            return n;
        }
        public String toString(){     //输出函数
            if(x==true){
                if(a==0)
                    qstr=(f+"+"+g+"=");
                if(a==1)
                    qstr=(f+"-"+g+"=");
                if(a==2)
                    qstr=(f+"×"+g+"=");
                if(a==3)
                    qstr=(f+"÷"+g+"=");
                if(a==4)  //新加的
                {
                	if(m==0)
                	{
                		qstr=("("+f+"-"+g+")*"+n+"=");
                	}
                	if(m==1)
                	{
                		qstr=("("+f+"+"+g+")*"+n+"=");
                	}
                }
            }
            if(x==false){
                if(a==0)
                    qstr=(compute11+"/"+compute21+"+"+compute31+"/"+compute41+"=");
                if(a==1)
                    qstr=(compute11+"/"+compute21+"-"+compute31+"/"+compute41+"=");
                if(a==2)
                    qstr=(compute11+"/"+compute21+"×"+compute31+"/"+compute41+"=");
                if(a==3)
                    qstr=(compute11+"/"+compute21+"÷"+compute31+"/"+compute41+"=");
            }
            return qstr;
        }
    }
    

    五、代码运行及码云截图





    然后点击复习就会回到一开始界面选择语言,选择题数。

    六、小结感受

      结对编程确实有一定的好处,当遇到问题时很快就解决了,效率提高了,任务也可以分工合作,也减轻了负担。虽然在修改的过程中问题很多,但一起解决感觉很好。还可以从对方身上学会更多的东西。从这个角度看好像满足结对编程带来‘1+1>2’这种说法。这次结对因为自己能力差一点很多都靠赵铭解决,所以收获挺大的。
    

    以下是结对的时候的部分聊天记录


    七、PSP表格

  • 相关阅读:
    Fastjson1.2.68 绕Autotype的一点总结
    MySQL外键约束冲突异常:com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Cannot add or update a child row: a foreign key constraint fails (...)
    SO_REUSEADDR
    Live2d Test Env
    Mac上使用virtualenv配置Python虚拟环境
    Mac环境下替换pip源方法
    Mac上安装Python3教程
    【ASP.NET Core学习】使用JWT认证授权
    LeetCode 110. 平衡二叉树 | Python
    LeetCode 733. 图像渲染 | Python
  • 原文地址:https://www.cnblogs.com/yayaya/p/8645736.html
Copyright © 2020-2023  润新知