zoukankan      html  css  js  c++  java
  • 201571030310/201571030329《小学四则运算训练软件》结对项目报告

    一.项目源码。

    Github地址:https://github.com/loadrove/SoftWareTest

    .项目报告

    1.需求分析:

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

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

         

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

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

     

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

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

      (7)程序人机交互界面是GUI界面(WEB页面、APP页面都可),界面支持中文简体。

    2.软件设计:

      (1)设计流程图:  

                         

     (2)设计类图

                     

      1> ReadFile类是读取所有文件,将生成的算式全部读出来,以栈的形式放入数组内;

      2> Fraction类是关于分数的计算,分为真分数和假分数;

      3> Calculate类是百内整数的加减乘除运算;

      4> Textview就是显示最终运算结果,以及显示分数,计时等功能。

     

    (3)核心代码:

      1>读取生成的文件:

                     

    2>分数的运算:

    public int getNumerator()  
            {  
                return c;  
            }  
            public int getDinominator()  
            {  
                return d;  
            }  
          
            public void selfTrim()  
            {  
                int maxCommon=commonDivisor(c,d);       //求出两个数的最大公约数。  
                c=c/maxCommon;                  //分式为最简。  
                d=d/maxCommon;  
                //整理正负号。  
                if((c>0&&d<0)||(c<0&&d<0))  
                {  
                    c=-c;  
                    d=-d;  
                }  
            }  
          
            public String toString()                        //重写tostring().  
            {  
                if(c==0||d==1)                          //分母为1 直接输出分子.  
                {  
                    return Integer.toString(c);  
                }  
                return Integer.toString(c)+"/"+Integer.toString(d);     //输出c/d.  
            }  
            //----- plus  
            public Fraction minus(Fraction f2)  
            {  
                int newNumerator=c*f2.getDinominator()-d*f2.getNumerator();  
                int newDinominator=d*f2.getDinominator();  
          
                int maxCommon=commonDivisor(newNumerator,newDinominator);  
                return new Fraction(newNumerator/maxCommon,newDinominator/maxCommon);  
            }  
            //---- minus  
            public Fraction plus(Fraction f2)  
            {  
                int newNumerator=c*f2.getDinominator()+d*f2.getNumerator();  
                int newDinominator=d*f2.getDinominator();  
          
                int maxCommon=commonDivisor(newNumerator,newDinominator);  
                return new Fraction(newNumerator/maxCommon,newDinominator/maxCommon);  
            }  
            
            
            //----- mutiply  
            public  Fraction multiply(Fraction f2)                  //两个分数相乘。  
            {  
                int newNumerator=c*f2.getNumerator();  
                int newDinominator=d*f2.getDinominator();  
          
                int maxCommon=commonDivisor(newNumerator,newDinominator);  
                return new Fraction(newNumerator/maxCommon,newDinominator/maxCommon);  
            }  
              
            //-----  divide  
            public Fraction divide(Fraction f2)  
            {  
                if(f2.getNumerator()==0)  
                {  
                    System.out.println("0不能做除数!");  
                    System.exit(0);  
                }  
                Fraction result=new Fraction(c,d);
                return result.multiply(new Fraction(f2.getDinominator(),f2.getNumerator()));
            }  
          
            //计算2个数的最大公约数。按绝对值计算。  

     

     

    3>整数的计算:

    private static Stack<String> count(Stack<String> result,boolean isF,int i) {
            if(!isF) {
                switch(i) {
                case 1:
                    String str1=Integer.parseInt(result.pop())+Integer.parseInt(result.pop())+"";
                    result.push(str1);
                    break;
                case 2:
                    String str2=-Integer.parseInt(result.pop())+Integer.parseInt(result.pop())+"";
                    result.push(str2);
                    break;
                case 3:
                    String str3=Integer.parseInt(result.pop())*Integer.parseInt(result.pop())+"";
                    result.push(str3);
                    break;
                case 4:
                    int x=Integer.parseInt(result.pop());
                    String str4=Integer.parseInt(result.pop())/x+"";
                    result.push(str4);
                    break;
                }
            }else {
                switch(i) {
                case 1:
                    if(fraction!=null) {
                        int x1=Integer.parseInt(result.pop());
                        int x2=Integer.parseInt(result.pop());
                        Fraction f1=new Fraction(x2,x1);
                        fraction=fraction.plus(f1);
                    }else {
                        int x1=Integer.parseInt(result.pop());
                        int x2=Integer.parseInt(result.pop());
                        Fraction f1=new Fraction(x2,x1);
                        int y1=Integer.parseInt(result.pop());
                        int y2=Integer.parseInt(result.pop());
                        Fraction f2=new Fraction(y2,y1);
                        fraction=f1.plus(f2);
                    }
                    break;
                case 2:
                    if(fraction!=null) {
                        int x1=Integer.parseInt(result.pop());
                        int x2=Integer.parseInt(result.pop());
                        Fraction f1=new Fraction(x2,x1);
                        fraction=fraction.minus(f1);
                    }else {
                        int x1=Integer.parseInt(result.pop());
                        int x2=Integer.parseInt(result.pop());
                        Fraction f1=new Fraction(x2,x1);
                        int y1=Integer.parseInt(result.pop());
                        int y2=Integer.parseInt(result.pop());
                        Fraction f2=new Fraction(y2,y1);
    
                    }
                    break;
                case 3:
                    if(fraction!=null) {
                        int x1=Integer.parseInt(result.pop());
                        int x2=Integer.parseInt(result.pop());
                        Fraction f1=new Fraction(x2,x1);
                        fraction=fraction.multiply(f1);
                    }else {
                        int x1=Integer.parseInt(result.pop());
                        int x2=Integer.parseInt(result.pop());
                        Fraction f1=new Fraction(x2,x1);
                        int y1=Integer.parseInt(result.pop());
                        int y2=Integer.parseInt(result.pop());
                        Fraction f2=new Fraction(y2,y1);
                        fraction=f1.multiply(f2);
                    }
                    break;
                case 4:
                    if(fraction!=null) {
                        int x1=Integer.parseInt(result.pop());
                        int x2=Integer.parseInt(result.pop());
                        Fraction f1=new Fraction(x2,x1);
                        fraction=fraction.divide(f1);
                    }else {
                        int x1=Integer.parseInt(result.pop());
                        int x2=Integer.parseInt(result.pop());
                        Fraction f1=new Fraction(x2,x1);
                        int y1=Integer.parseInt(result.pop());
                        int y2=Integer.parseInt(result.pop());
                        Fraction f2=new Fraction(y2,y1);
                        fraction=f2.divide(f1);
                    }
                    break;
                }
            }
            return result;
        }
        
        
        
        private static Stack<String> toNumberStack(Stack<String> s){
            Stack<String>numbers=new Stack<String>();
            for(int i=0;i<s.size();i++) {
                if(!s.get(i).equals("+")&&!s.get(i).equals("-")&&!s.get(i).equals("*")&&!s.get(i).equals("/")
                        &&!s.get(i).equals("÷")) {
                    System.out.print(s.get(i)+",");
                    numbers.push(s.get(i));
                }
            }
            return numbers;
        }

     (4)运行结果:                            

                                                                        

     测试结果统计:

       (5)本次设计的PSP:

    PSP2.1

    任务内容

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

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

    Planning

    计划

    9

    14

    Estimate

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

    0.5

    1.5

    Development

    开发

    9

    10.5

    Analysis

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

    1

    0.5

     Design Spec

    生成设计文档

    0.5

    0.5

    Design Review

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

    0.5

    0.5

    Coding Standard

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

    0.5

    0.5

     Design

      具体设计

    1

    1

    Coding

    具体编码

    4

    6

    Code Review

    代码复审

    1

    1

     Test

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

    0.5

    0.5

    Reporting

    报告

    1.5

    1.25

    Test Report

    ·  测试报告

    0.5

    0.5

    Size Measurement

      计算工作量

    0.5

    0.25

    Postmortem & Process Improvement Plan

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

    0.5

    0.5

    (6)请使用汉堡评价法给你的小伙伴一些点评。

      

         和我合作的小伙伴是一个思维能力很强的人,并且也很有想法,他的编程能力很强。在项目规划设计前期,我原本的计划是用Java设计一个面向对象的用户界面,他提出了他的想法,他想用上学期所学的安卓开发技术来做一个APP用户界面,我们通过讨论,觉得他的方法可行,并且比用Eclipse中开发设计要简单许多,通过使用他的策略,使得项目开发节省了很多时间。和他合作开发这个小项目的过程中,我提高了很多,改变了我的一些原来的软件设计思路。两个人通过努力,基本上实现了老师的项目要求,合作的也很愉快,期待能在以后的项目开发中继续能和他合作。

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

          结对编程真的能够带来1+1>2的效果,这是值得肯定的。在本次实验项目开发中,我俩分工合作,我主要负责题目的运算和分数统计,和我的伙伴他主要开发设计用户界面,以及计时器等;我们两个人合作完成项目,能够互相发现编程中存在的问题与不足,共同思考遇到的难题,两个人的思考能够把问题考虑的更加全面,也能让算法更优,这些都是一个人无法做到的。我也在此次开发编程中发现自己的代码比较乱,条理不是很清晰,这些是我的不足,我应该要向伙伴多学习和请教,使得我的代码更加完美,让自己的能力得到提高。我也确确实实感受到了团队合作的力量有很大的潜力。

     

  • 相关阅读:
    For each db / table
    转---网络上来的,做一个数组样的结构
    JAVA 相关资料
    转--也不知是哪位大侠写的了
    T-SQL切割字符串方法小结 2
    OPENQUERY
    行集函数专题
    行列转换
    第一章 SQL基础
    解释型语言与编译型语言的区别
  • 原文地址:https://www.cnblogs.com/yhy618/p/8690059.html
Copyright © 2011-2022 走看看