zoukankan      html  css  js  c++  java
  • 结对编程

    结对编程-四则运算

     

    组员

        陈福鹏 201421122096

        林栋  201421122098

    代码地址:https://gitee.com/helloc14/JieDuiXiangMu.git

     

    本次作业的完成内容

        本次作业基于作业一四则运算程序做增量开发,新增了如下功能

        1、实现了web界面。

        2、保存历史的错题和对题的数量,用于参考。

        3、计时功能,用于计算本次练习的所花时间。

     4、界面支持中文简体/中文繁体/英语用户可以选择一种。

    需求分析

        在练习四则运算题目的时候,我们需要参考原来做题的正确率,来了解一下自己的实力。有时候我们做练习题不仅需要得到题目的正确率,还需要在限定时间内完成练习,这时候需要这个程序有一个计时功能,在开始练习的时候开始计时,到练习完成计算所花时间。记录题目正确率需要统计每一次的练习,这样能保证这个正确率的参考性,将数据保存到本地文本文件,使数据持久化。用户也需要良好的界面来操作程序,还需要对程序的界面进行优化。

    程序设计

    我负责做的是答题数量的记录,在程序退出后再次进入能在原来的数量上叠加,以及错误题数的记录:

    项目的思维导图如下:

     

     

    代码展示

    实现答题数量记录,错题记录

    复制代码

    public void WriteGradeFile(String f,String[] str ,String time) throws IOException{
    String[] grade=new String[4];
    grade[0]="TotalCorrect: ";
    grade[1]="TotalWrong: ";
    grade[2]="TotalRepeat: ";
    grade[3]="ThisTestUsedTime: "+time;
    int c=0,w=0,r=0;
    File file=new File("C:\Arithmetic\grade.txt");
    if(file.exists()==true){
    System.out.println(c+"fff");
    FileReader fr=new FileReader(file);
    BufferedReader b = new BufferedReader(fr);
    String[] rub=new String[2];
    rub= b.readLine().split("\:");
    System.out.println(rub[1]+"fff");
    c=Integer.parseInt(rub[1].trim());
    System.out.println(c+"fff");
    rub= b.readLine().split("\:");
    w=Integer.parseInt(rub[1].trim());
    rub= b.readLine().split("\:");
    r=Integer.parseInt(rub[1].trim());
    b.close();
    fr.close();
    System.out.println(c+"fff");
    }
    String[] ans=new String[str.length];
    try {
    BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(f)),"UTF-8"));
    String lineTxt = null;
    int j=1;
    while ((lineTxt = br.readLine()) != null) {
    try {
    String[] rub=new String[2];
    rub= lineTxt.split("\)");
    ans[j-1]=rub[1].trim();
    if(ans[j-1].equals(str[j-1])){
    c++;
    }
    else{
    w++;
    }
    }
    catch (Exception e) {
    // TODO Auto-generated catch block
    //System.out.println(j+" 答案为空");
    w++;
    }
    j++;
    }
    br.close();
    } catch (Exception e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    grade[0]=grade[0]+c;
    grade[1]=grade[1]+w;
    grade[2]=grade[2]+r;

    if(file.exists()==true){
    file.delete();
    }
    file.createNewFile();
    FileWriter fileWritter = new FileWriter(file,true);
    BufferedWriter bufferWritter = new BufferedWriter(fileWritter);
    for(int i=0;i<grade.length;i++){
    bufferWritter.write(i+1+". "+grade[i]);
    bufferWritter.newLine();
    }
    bufferWritter.close();
    fileWritter.close();
    }
    public void WriteStringFile(String f,String str) throws IOException{
    System.out.println(count);
    File file=new File(f);
    if(count==1||file.exists()==false){
    if(file.exists()==true){
    file.delete();
    }
    file.createNewFile();
    }
    System.out.println(file.getAbsolutePath());
    FileWriter fw = new FileWriter(file, true);
    BufferedWriter bw = new BufferedWriter(fw);
    // bw.append("在已有的基础上添加字符串");
    if(f.equals("C:\Arithmetic\math.txt")){
    bw.write("("+count+") "+str+"= ");// 往已有的文件上添加字符串
    }
    else{
    bw.write("("+count+") "+str+" ");// 往已有的文件上添加字符串
    }
    bw.close();
    fw.close();
    }
    public int getTextLines(String path) throws IOException {
    FileReader fr = new FileReader(path); //这里定义一个字符流的输入流的节点流,用于读取文件(一个字符一个字符的读取)
    BufferedReader br = new BufferedReader(fr); // 在定义好的流基础上套接一个处理流,用于更加效率的读取文件(一行一行的读取)
    int x = 0; // 用于统计行数,从0开始
    while(br.readLine() != null) { // readLine()方法是按行读的,返回值是这行的内容
    x++; // 每读一行,则变量x累加1
    }
    return x; //返回总的行数
    }

    复制代码

    程序运行截图:

    结对过程

      队友是使用java实现的,本人是使用c++实现的,所以在谁的基础上进行修改有了一番讨论,最终决定不使用qt,使用web实现。

     展示PSP

    PSP2.1 

    Personal Software Process Stages

    Time Senior Student

    Time 

    Planning

    计划

    16

    25

    · Estimate

    估计这个任务需要多少时间

    15

    22

     Development

    开发

    552

    573

     ·Analysis

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

    40

    35

    · Design Spec

    生成设计文档

    30

    25

    · Design Review

    设计复审

    15

    23

     · Coding Standard

    代码规范

    16

    15

    · Design

    具体设计

    46

    35

    · Coding

    具体编码

    264

    263

    · Code Review

    代码复审

    40

    26

     · Test

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

    40

    50

     Reporting

    报告

    63

    84

     

    测试报告

    10

    8

     

    计算工作量

    14

    13

     

    并提出过程改进计划

    15

    17

    小结感受

    在结对编程中,最近忙着找工作,没啥心思做了,而且最终采用web实现功能,java web的东西快忘得差不多了,所以交流跟负责的会比较少

    评价合作伙伴

    队友很给力,也挺体谅我的,总有那么个时间段是抽不开身的。

  • 相关阅读:
    Mysql登录错误:ERROR 1045 (28000): Plugin caching_sha2_password could not be loaded
    Docker配置LNMP环境
    Docker安装mysqli扩展和gd扩展
    Docker常用命令
    Ubuntu常用命令
    单例模式的优缺点和使用场景
    ABP 多租户数据共享
    ABP Core 后台Angular+Ng-Zorro 图片上传
    ERROR Error: If ngModel is used within a form tag, either the name attribute must be set or the form control must be defined as 'standalone' in ngModelOptions.
    AbpCore 执行迁移文件生成数据库报错 Could not find root folder of the web project!
  • 原文地址:https://www.cnblogs.com/helloc14/p/7711343.html
Copyright © 2011-2022 走看看