小伙伴:林卓辉
传送门:https://www.cnblogs.com/littlehui3/p/11688800.html
一 、Github项目地址:https://github.com/Mr-Gsh/Pair-programming
二、PSP2.1表格
PSP2.1 |
Personal Software Process Stages |
预估耗时(分钟) |
实际耗时(分钟) |
Planning
扫描二维码关注公众号,回复:
7483011 查看本文章
|
计划 |
30 |
60 |
· Estimate |
· 估计这个任务需要多少时间 |
30 |
60 |
Development |
开发 |
1085 |
1210 |
· Analysis |
· 需求分析 (包括学习新技术) |
60 |
70 |
· Design Spec |
· 生成设计文档 |
35 |
40 |
· Design Review |
· 设计复审 (和同事审核设计文档) |
50 |
60 |
· Coding Standard |
· 代码规范 (为目前的开发制定合适的规范) |
30 |
40 |
· Design |
· 具体设计 |
60 |
90 |
· Coding |
· 具体编码 |
800 |
850 |
· Code Review |
· 代码复审 |
50 |
60 |
· Test |
· 测试(自我测试,修改代码,提交修改) |
100 |
110 |
Reporting |
报告 |
110 |
135 |
· Test Report |
· 测试报告 |
30 |
45 |
· Size Measurement |
· 计算工作量 |
30 |
30 |
· Postmortem & Process Improvement Plan |
· 事后总结, 并提出过程改进计划 |
50 |
60 |
合计 |
|
1225 |
1405 |
三、效能分析
本项目主要针对判重方法进行了改进,第一个版本对“程序一次运行生成的题目不能重复”这个审题不算很仔细,只是简单利用了:
1.结果相同
2.符号相同
3.数量相同
以此来解决,但在编写以及最后运行发现花费时间较长,要遍历很多遍,而且发现没有符合题目要求左结合的特性,而是全部算作重复,于是推翻了第一个版本,由同伴提出的二叉树来解决判重方法,也不需要加很多循环以及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的编程用法,在同学的帮助下也改变了不少之前编程的不算很规范的地方,也学习了很多新用法新思想。