zoukankan      html  css  js  c++  java
  • 20172318 结对编程项目-四则运算 第一周 阶段总结

    结对对象

    • 学号 20172312 20172315
    • 姓名 彭霖 胡智韬
    • 担任角色
      陆大岳 生成题目 编写主类
      胡智韬 中缀转后缀 计算
      彭霖 分数

    需求分析

    • 生成分级的题目
      目前的代码编写只写了第一级(一个运算符)和第二级(两个运算符),有需要可以再加
    • 指定生成题目的数量
      放main方法里,用循环解决
    • 支持真分数
      把运算弄成分数的运算,还在写
    • 答案
      计算时用数组将每题答案记录并在最后输出
    • 正确率
      统计回答者的正确题数和题数的比值
    • 拓展
      去重暂时不会

    设计思路

    • 设计calculate类,实现填入生成题目等级,填入题目数量,输出答案和正确率的功能
      我写的

    import java.util.Scanner;
    public class calculate {
    public static void main(String[] args) {
    System.out.println("输入你要生成的题数");
    Scanner scan = new Scanner(System.in);
    int tishu = scan.nextInt();
    System.out.println("输入你要生成题目的等级(输入1或2)");
    int dengji = scan.nextInt();
    //调用一个循环
    double answer;
    int zhengquelv=0;
    double[] daan=new double[tishu];
    if (dengji == 1)
    for (int i = 0; i < tishu; i++) {
    String a = createquestions.create(1);
    String b = a+"=";
    System.out.print(b);
    answer=scan.nextDouble();
    daan[i]=StringToArithmetic.stringToArithmetic(a);
    if(answerdaan[i])
    zhengquelv++;
    }
    else if (dengji == 2)
    for (int i = 0; i < tishu; i++) {
    String a = createquestions.create(2);
    String b = a+"=";
    System.out.print(b);
    answer=scan.nextInt();
    daan[i]=StringToArithmetic.stringToArithmetic(a);
    if(answer
    daan[i])
    zhengquelv++;
    }
    else
    System.out.println("题目等级输入错误");
    if(dengji1||dengji2) {
    System.out.println("答案为");
    for (double daanwei : daan)
    System.out.print(daanwei + " ");
    System.out.println("正确率为" + zhengquelv+ "/"+ tishu);
    }
    }
    }

    • 设计createquestions类,实现生成题目的功能,支持括号,支持生成分数
      我写的,数字只包括十以内,因为计算的程序还没写好,不能进行10以上的计算

    public class createquestions {
    public static String create(int level){
    String add = "+", sub = "-", multi = "×", div = "÷";
    String result="";
    int r1=(int)(Math.random()9+1);
    int r2=(int)(Math.random()
    9+1);
    int r3=(int)(Math.random()9+1);
    int fenzi1=(int)(Math.random()
    9+1);
    int fenmu1=(int)(Math.random()9+1);
    String fenshu1=fenzi1+"/"+fenmu1;
    int fenzi2=(int)(Math.random()
    9+1);
    int fenmu2=(int)(Math.random()9+1);
    String fenshu2=fenzi2+"/"+fenmu2;
    int fenzi3=(int)(Math.random()
    9+1);
    int fenmu3=(int)(Math.random()9+1);
    String fenshu3=fenzi3+"/"+fenmu3;
    int suiji1=(int)(Math.random()
    4);
    //第一个运算符
    int suiji11=(int)(Math.random()3);
    //生成括号
    int suiji2=(int)(Math.random()
    4);
    //第二个运算符
    int suiji31=(int)(Math.random()4);
    //生成分数1概率
    int suiji32=(int)(Math.random()
    4);
    //生成分数2概率
    int suiji33=(int)(Math.random()*4);
    //生成分数3概率
    if (level1||level2) {
    if(suiji110&&level2)
    result+="(";
    if (suiji313)
    result+=fenshu1;
    else
    result+=r1;
    if (suiji1 == 0)
    result+=add;
    if (suiji1 == 1)
    result+=sub;
    if (suiji1
    2)
    result+=multi;
    if(suiji13)
    result+=div;
    if(suiji11
    1&&level2)
    result+="(";
    if (suiji32
    3)
    result+=fenshu2;
    else
    result+=r2;
    if(suiji110&&level2)
    result+=")";
    }
    if (level2){
    if (suiji2
    0)
    result+=add;
    if (suiji2 == 1)
    result+=sub;
    if (suiji22)
    result+=multi;
    if(suiji2
    3)
    result+=div;
    if (suiji333)
    result+=fenshu3;
    else
    result+=r3;
    if(suiji11
    1)
    result+=")";
    }
    return result;
    }
    }

    • 设计StringToArithmetic类,实现中缀转后缀,后缀计算的功能
      胡智韬负责,还没支持分数的运算(彭霖负责),半成品,能进行简单的加减乘除

    PSP时间统计

    PSP2.1 Personal Software Process Stages 预估耗时(分钟) 实际耗时(分钟)
    Planning 计划 55 75
    Estimate 估计这个任务需要多少时间 3 5
    Development 开发 200 300
    Analysis 需求分析 (包括学习新技术) 30 60
    Coding Standard 代码规范 (为目前的开发制定合适的规范) 30 15
    Design UML 设计项目UML类图 60 10
    Coding 具体编码 200 200
    Code Review 代码复审 20 20
    Test 测试(自我测试,修改代码,提交修改) 50 50
    Size Measurement 计算工作量(实际时间) 10 10
    Postmortem & Process Improvement Plan 事后总结, 并提出过程改进计划 100 100
    合计 758 845
  • 相关阅读:
    0909《操作系统教程》理解和认识
    1230《操作系统教程》实验四 主存空间的分配和回收模拟
    1203《操作系统教程》实验三 进程调度模拟程序 ——实验点评
    1203《操作系统教程》实验三 进程调度模拟程序
    1111《操作系统教程》实验二 作业调度模拟程序
    实验四 主存空间的分配和回收模拟
    实验三同学互评
    实验三 进程调度模拟程序
    实验二、作业调度模拟实验
    实验一报告
  • 原文地址:https://www.cnblogs.com/m1sty/p/8977958.html
Copyright © 2011-2022 走看看