20165333实验三 敏捷开发与XP实践

时间:2023-03-09 16:59:40
20165333实验三 敏捷开发与XP实践

实验内容

一、参考 http://www.cnblogs.com/rocedu/p/6371315.html#SECCODESTANDARD 安装alibaba 插件,解决代码中的规范问题。

在IDEA中使用工具(Code->Reformate Code)把下面代码重新格式化,再研究一下Code菜单,找出一项让自己感觉最好用的功能。提交截图,加上自己学号水印。

代码规范前

public class CodeStandard {
public static void main(String [] args){
StringBuffer buffer = new StringBuffer();
buffer.append('S');
buffer.append("tringBuffer");
System.out.println(buffer.charAt(1));
System.out.println(buffer.capacity());
System.out.println(buffer.indexOf("tring"));
System.out.println("buffer = " + buffer.toString());
if(buffer.capacity()<20)
buffer.append("1234567");
for(int i=0; i<buffer.length();i++)
System.out.println(buffer.charAt(i));
}
}

规范后

20165333实验三 敏捷开发与XP实践

二、在码云上把自己的学习搭档加入自己的项目中,确认搭档的项目加入自己后,下载搭档实验二的Complex代码,加入不少于三个JUnit单元测试用例,测试成功后git add .; git commit -m "自己学号 添加内容";git push;

提交搭档项目git log的截图,包含上面git commit的信息,并加上自己的学号水印信息。

代码如下

 class Complex {
private double r;
private double i; public Complex(double r, double i) {
this.r = r;
this.i = i;
}
public static double getRealPart(double r) {
return r;
}
public static double getImagePart(double i) {
return i;
} public Complex ComplexAdd(Complex a) {
return new Complex(r + a.r, i + a.i);
} public Complex ComplexSub(Complex a) {
return new Complex(r - a.r, i - a.i);
}
public Complex ComplexMulti(Complex a) {
return new Complex(r * a.r - i * a.i , r * a.i + i * a.r);
}
public Complex ComplexDiv(Complex a) {
return new Complex((r * a.i + i * a.r) / (a.i * a.i + a.r * a.r), (i * a.i + r * a.r) / (a.i * a.i + a.r * a.r));
}
public String toString() {
String s =" ";
if (i > 0)
s =r +"+"+ i +"i";
if (i == 0)
s =r+"";
if (i < 0)
s = r +" "+ i+"i";
return s;
}
}

20165333实验三 敏捷开发与XP实践

20165333实验三 敏捷开发与XP实践

三、完成重构内容的练习,下载搭档的代码,至少进行三项重构,提交重构后代码的截图,加上自己的学号水印。提交搭档的码云项目链接。

20165333实验三 敏捷开发与XP实践

实验感受

通过这次实验让我再一次体会到团队的力量,思维碰撞的火花,结对学习让学习效率得到提高,两个人长短互补,而且督促双方学习,有效学习的时间变长。