Pair programming operations implemented java

Small partners: Lin Zhuohui 

Portal: https://www.cnblogs.com/littlehui3/p/11688800.html


 

A, Github project Address: https://github.com/Mr-Gsh/Pair-programming


 

Two, PSP2.1 table

PSP2.1

Personal Software Process Stages

Estimated time consuming (minutes)

The actual time-consuming (minutes)

Planning

plan

 30

 60

· Estimate

• Estimate how much time this task requires

 30

 60

Development

Develop

 1085

 1210

· Analysis

· Needs analysis (including learning new technologies)

 60

70

· Design Spec

Generate design documents

 35

 40

· Design Review

· Design Review (and his colleagues reviewed the design documents)

 50

 60

· Coding Standard

· Code specifications (development of appropriate norms for the current development)

 30

 40

· Design

· Specific design

 60

 90

· Coding

· Specific coding

 800

 850

· Code Review

· Code Review

 50

 60

· Test

· Test (self-test, modify the code, submit modifications)

 100

 110

Reporting

report

 110

 135

· Test Report

· testing report

 30

 45

· Size Measurement

· Computing workload

 30

 30

· Postmortem & Process Improvement Plan

· Hindsight, and propose process improvement plan

 50

 60

total

 

 1225

 1405

Third, performance analysis

The project mainly for re-sentenced to an improved method, the first version of the "Program run generated task can not be repeated," this is not very careful moderation, simply use the:

1. The same result

2. The same symbol

3. The same number

以此来解决,但在编写以及最后运行发现花费时间较长,要遍历很多遍,而且发现没有符合题目要求左结合的特性,而是全部算作重复,于是推翻了第一个版本,由同伴提出的二叉树来解决判重方法,也不需要加很多循环以及if语句,最终在运行时间上速度有所提升且符合题目左结合的要求。


 

四、设计实现过程


 

五、代码说明

一共分了六个类来完成这次作业,分别是Main,Node,SymNode,Question,Fract,FileUtils。

其中Node和SymNode是数字与符号的节点类

 

package main;

public class Node implements Cloneable{
    Fract r;
    Node ri;
    Node le;
    int h;

    Node(Fract r, Node ri, Node le, int h) {
        this.r = r;
        this.ri = ri;
        this.le = le;
        this.h = h;
    }

    @Override
    public String toString() {
        return r.toString();
    }

    @Override
    protected Object clone() throws CloneNotSupportedException{
        Node node = (Node)super.clone();
        Node right = node.ri;
        Node left = node.le;
        if (right != null) {
            node.ri = (Node)right.clone();
        }
        if (left != null) {
            node.le = (Node)left.clone();
        }
        return node;
    }

    @Override
    public boolean equals(Object o) {
        if(this == o) return true;
        if((o==null)||(getClass() != o.getClass())) return false;

        Node node = (Node) o;

        if(r != null){
            if(!r.equals(node.r)){
                return false;
            }
        }else{
            if(node.r!=null){
                return false;
            }
        }
        if(r != null){
            if(!ri.equals(node.ri)){
                return false;
            }
        }else{
            if(node.ri != null){
                return false;
            }
        }
        if(le != null){
            return le.equals(node.le);
        }else{
            return node.le == null;
        }
    }

 

package main;

public class SymNode extends Node{
    String sym;

    SymNode(Node ri, Node le, String sym) {
        super(null,ri,le,0);
        this.sym = sym;
    }

    @Override
    public String toString() {
        return " "+sym+" ";
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        SymNode that = (SymNode) o;
        if (this.h != that.h) {
            return false;
        }
        boolean flag = (sym != null? sym.equals(that.sym) : that.sym == null);
        if (!flag) {
            return false;
        }
        boolean left = this.le != null? this.le.equals(that.le) : that.le == null;
        boolean right = this.ri != null? this.ri.equals(that.ri) : that.ri == null;

        if (left && right) {
            return true;
        }
        if (left ^ right) {
            return false;
        }
        if (that.sym == null) {
            return false;
        }
        if (this.sym.equals("+") || this.sym.equals("×")) {
            left = (this.le != null) && (this.le.equals(that.ri));
            right = (this.ri != null) && (this.ri.equals(that.le));
        }
        return left&&right;
    }

    @Override
    public int hashCode() {
        int result = super.hashCode();
        result = 31 * result + (sym != null ? sym.hashCode() : 0);
        return result;
    }
}

 

六、测试运行

 

 先把参数都设为10

 

 生成了带有时间的文件

 

 两个文件

 

 修改参数

 

 再次生成新的文件

 

 参数为50 10的题目与答案文件


 

七、总结

通过这次项目,了解了结对项目,之前一直认为结对编程就是两个人分开任务自己去完成,看过《构建之法》才明白原来是要分驾驶员与领航员,两个人共同完成一个项目,在编写过程中实际也就是检查代码,相对减少了之后代码复审的工作时间。总体上这次项目基本完成,对于结对编程有了大概了解,体会到了相互讨论的好处,也更加熟悉了java的编程用法,在同学的帮助下也改变了不少之前编程的不算很规范的地方,也学习了很多新用法新思想。

 

Guess you like

Origin www.cnblogs.com/Mr-Gsh/p/11689702.html