羊四七呀

导航

结对作业

一、前言

代码地址:https://git.coding.net/sheep47/sizeyunsuan.2.git

这次结对作业,我们组本来打算做成网页版的,并且我的队友刘士齐已经写好了前端界面,但最后还是选择了GUI。。。辛苦士齐了。。。

吸取教训:作业又又拖到最后才做,时间非常紧迫,边学边写效率非常慢,希望老师可以在课上指导一些做作业的方法。

二、PSP

Personal Software Process Stages

计划时间(min)

完成时间(min)

计划

40 60
估计这个任务需要多少时间 600 1200
开发 240 300
需求分析(包括学习新技术) 30 20
生成设计文档 0 0
设计复审 0 0
代码规范 30 30
具体设计 30 40
具体编码 180 300
代码复审 30 30
测试(自我测试,修改代码,提交修改) 30 60
报告 30 90
测试报告 30 20
计算工作量 30 60
并提出过程修改计划 240 180

 

三、接口设计

1、Information Hiding:信息隐藏指在设计和确定模块时,使得一个模块内包含的特定信息(过程或数据),对于不需要这些信息的其他模块来说,是不可访问的。

2、 Interface Design, Loose Coupling:这两个概念近乎是相似的,后者是前者的目的,前者是后者的实现手段。定义一套公共的接口,方便各个模块之间的通讯。面向接口的程序设计思想是一种有效的手段。接口是抽象方法的集合,接口通常以interface来声明。一个类通过继承接口的方式,从而来继承接口的抽象方法。接口并不是类,编写接口的方式和类很相似,但是它们属于不同的概念。一个实现接口的类,必须实现接口内所描述的所有方法,否则就必须声明为抽象类。松耦合发生在依赖类包含一个指针只有一个接口,然后可以通过一个或多个具体的类实现。依赖类的依赖是一种“合同”指定的接口;定义列表的方法和/或特性,实现类必须提供。

四、计算模块接口的设计与实现过程

在本次作业中,我们一共设计了四个类。Background类,包括testNum(题目数量),question(储存题目的数组),result(储存答案的数组);Fraction类,包括qstr(储存题目的字符串),astr(储存答案的字符串);Integer类,包括qstr(储存题目的字符串),astr(储存答案的字符串);MyWindows类,testNum(题目数量),question(储存题目的数组),result(储存答案的数组),rightNum(文件读出的正确数量),errorNum (文件读出的错误数量r),ightNum2 (本次正确数量),errorNum2 (本次错误数量),answers (储存用户的回答)。

五、计算模块部分单元测试展示

六、运行界面展示

 

 

 

 

 

七、模块设计

 1 public class Fraction {
 2 
 3         int a = new Random().nextInt(4);
 4         int b = new Random().nextInt(10)%(10-1+1) + 1;
 5         int c = new Random().nextInt(10)%(10-2+1) + 2;
 6         int d = new Random().nextInt(10)%(10-1+1) + 1;
 7         int e = new Random().nextInt(10)%(10-2+1) + 2;
 8         String astr="";
 9         String qstr="";
10         
11         public String fra_operation(){      
12             if(c<b)
13             {
14                 int temp;
15                 temp = c;
16                 c = b;
17                 b = temp;
18             }
19             if(e<d){
20                 int temp;
21                 temp = e;
22                 e = d;
23                 d = temp;
24             }
25                 
26             int fz=1,fm=c*e;
27             
28             if(a==0)
29                 fz=b*e+c*d;            
30             if(a==1){
31                 fz=b*e-c*d;
32                 if(fz==0)
33                 {
34                     return astr=("0");
35                 }
36             }                
37             if(a==2)
38                 fz=b*d;            
39             if(a==3)
40             {
41                 fz=b*e;
42                 fm=c*d;
43             }            
44             int f=common_divisor(fm,fz);
45             if(f>0){
46                 fm=fm/f;
47                 fz=fz/f;
48             }
49             if(f<0){
50                 fm=-fm/f;
51                 fz=-fz/f;
52             }
53             if(fm!=1)
54                 astr = (fz+"/"+fm);
55             else
56                 astr=(""+fz);
57             
58             return astr;            
59         }
60         
61         public static int common_divisor(int m,int n)
62         {
63             while(m%n!=0){
64                 int t=m%n;
65                 m=n;
66                 n=t;
67             }
68             return n;
69         }
70         
71         public String toString(){
72             if(c<b)
73             {
74                 int temp;
75                 temp = c;
76                 c = b;
77                 b = temp;
78             }
79             if(e<d){
80                 int temp;
81                 temp = e;
82                 e = d;
83                 d = temp;
84             }                    
85             if(a==0)
86                 qstr=(b+"/"+c+"+"+d+"/"+e+"=");
87             if(a==1)
88                 qstr=(b+"/"+c+"-"+d+"/"+e+"=");
89             if(a==2)
90                 qstr=(b+"/"+c+"×"+d+"/"+e+"=");
91             if(a==3)
92                 qstr=(b+"/"+c+"÷"+d+"/"+e+"=");
93             return qstr;
94         }
95         
96 }
 1 public class Integer {
 2     
 3     int a = new Random().nextInt(4);
 4     int b = new Random().nextInt(100);
 5     int c = new Random().nextInt(100);
 6     String astr="";
 7     String qstr="";
 8     
 9     public String int_operation(){
10         int result = 0;
11         if(a==0)
12             result=b+c;
13         if(a==1)
14             result=b-c;
15         if(a==2)
16             result=b*c;
17         astr = String.valueOf( result);
18         if(a==3)
19         {
20             if(c==0)
21             {
22                 astr=int_operation();
23                 return astr;
24             }
25             else
26             {
27                 if(c!=1){
28                     int d=common_divisor(b,c);
29                     b=b/d;
30                     c=c/d;
31                     astr = (b+"/"+c);
32                 }
33                 if(c==1)
34                     astr=(""+b);
35             }
36             
37         }
38         return astr;
39     }
40     
41     public static int common_divisor(int m,int n)
42     {
43         while(m%n!=0){
44             int t=m%n;
45             m=n;
46             n=t;
47         }
48         return n;
49     }
50     
51     public String toString(){        
52         if(a==0)
53             qstr=(b+"+"+c+"=");
54         if(a==1)
55             qstr=(b+"-"+c+"=");
56         if(a==2)
57             qstr=(b+"×"+c+"=");
58         if(a==3)
59             qstr=(b+"÷"+c+"="); 
60         return qstr;
61     }
62     
63 }
 1 public void History() {
 2         
 3         try {
 4             reader = new BufferedReader(new FileReader(new File("history.txt")));
 5             rightNum = reader.readLine();
 6             errorNum = reader.readLine();
 7             reader.close();
 8         } catch (IOException e) {
 9             e.printStackTrace();
10         }
11         labRight.setText("历史正确量:"+ rightNum );  
12         labError.setText("历史错误量:"+ errorNum );          
13     }

 

八、结对过程

总结一下这次结对作业的过程,由于我和parter都太过佛性,所以一开始并没有找好作业的方向,以至于白忙活了几天,最后却发现有很多不能解决的问题,于是只能在作业截止两天前重新开始,用gui的方法完成项目。找出java课本,对以前学过的知识进行巩固,应用到实际中,但无奈时间太过紧迫,只能做出一份比较粗糙的作业。。。感谢我parter给我的鼓励和帮助,我们在结对过程中并没有产生分歧或者不愉快的争吵,虽然出现了很多问题,也慢慢地讨论着想办法解决,很喜欢我的队友~~让我的这次作业不是单打独斗,而是互相扶持,有了很多的动力,也提高了巨慢的效率。

下面总结一下我们两人的优缺点

刘士奇 优点:仔细认真,善于发现问题、代码规范,清晰易懂、动手能力强,有责任心

            缺点:太认真仔细,以至于速度有点慢

我        优点:态度认真、善于沟通交流、善于学习

            缺点:效率低、时间规划不好、粗心马虎

posted on 2018-04-10 08:05  羊四七呀  阅读(159)  评论(1编辑  收藏  举报