实验三 敏捷开发与XP实践 http://www.cnblogs.com/rocedu/p/4795776.html, Eclipse的内容替换成IDEA
参考 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));
}
}
/**
* CodeStandard
*
* @author 16487
* @date 2019/4/28
*/
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());
int n = 20;
if (buffer.capacity() < n){
buffer.append("1234567");
}
for (int i = 0; i < buffer.length(); i++){
System.out.println(buffer.charAt(i));
}
}
}
Surround With
(使用if-else、for、while等语句包装代码段)) Ctrl+Alt+T
Comment with Line Comment
( 行注释 ) Ctrl + /
在码云上把自己的学习搭档加入自己的项目中,确认搭档的项目加入自己后,下载搭档实验二的Complex代码,加入不少于三个JUnit单元测试用例,测试成功后git add .; git commit -m "自己学号 添加内容";git push;
提交搭档项目git log的截图,包含上面git commit的信息,并加上自己的学号水印信息。
在码云上把自己的学习搭档加入自己的项目中并下载学习搭档的代码
加入不少于三个JUnit
单元测试用例并测试
上传至码云
/**
* @Author 16487
*/
public class lyxComplex {
double a,b;
lyxComplex(double m,double n){//构造函数设置实部虚部
a=m;
b=n;
}
public double getRealPart(){//返回实部
return a;
}
public double getImagePart() {//返回虚部
return b;
}
public lyxComplex ComplexAdd(lyxComplex y){//加法
double m=y.getRealPart();
double n=y.getImagePart();
double x=a+m;
double z=b+n;
return new lyxComplex(x,z);
}
public lyxComplex ComplexSub(lyxComplex y){
double m=y.getRealPart();
double n=y.getImagePart();
double x=a-m;
double z=b-n;
return new lyxComplex(x,z);
}
public lyxComplex ComplexMulti(lyxComplex y){
double m=y.getRealPart();
double n=y.getImagePart();
double x=a*m;
double z=b*n;
return new lyxComplex(x,z);
}
public lyxComplex ComplexDiv(lyxComplex y){
double m=y.getRealPart();
double n=y.getImagePart();
double x=a/m;
double z=b/n;
return new lyxComplex(x,z);
}
@Override
public java.lang.String toString() {
String s="";
if (a!=0&&b>0&&b!=1){
s+= a+"+"+ b+"i";
}
else if(a!=0&&b==1){
s+=a+"+i";
}
else if (a!=0&&b<0&&b!=-1){
s+= a+""+b+"i";
}
else if (a!=0&&b==-1){
s+=a+"-i";
}
else if (a!=0&&b==0){
s+=a;
}
else if (a==0&&b!=0){
s+=b+"i";
}
else if (a==0&&b==0){
s+="0.0";
}
return s;
}
}
/**
* @Author 16487
*/
import junit.framework.TestCase;
import org.junit.Test;
public class lyxComplexTest extends TestCase {
lyxComplex a=new lyxComplex(0,0);
lyxComplex b=new lyxComplex(1,1);
lyxComplex c=new lyxComplex(-1,-1);
lyxComplex d=new lyxComplex(20.16,53.10);
lyxComplex e=new lyxComplex(2,3);
@Test
public void testgetReal(){
assertEquals(0.0,a.getRealPart());
assertEquals(-1.0,c.getRealPart());
assertEquals(20.16,d.getRealPart());
}
@Test
public void testgetIma(){
assertEquals(0.0,a.getImagePart());
assertEquals(-1.0,c.getImagePart());
assertEquals(53.1,d.getImagePart());
}
@Test
public void testComAdd(){
assertEquals("0.0",b.ComplexAdd(c).toString());
assertEquals("1.0+i",a.ComplexAdd(b).toString());
assertEquals("19.16+52.1i",c.ComplexAdd(d).toString());
assertEquals("-1.0-i",a.ComplexAdd(c).toString());
assertEquals("21.16+54.1i",b.ComplexAdd(d).toString());
assertEquals("20.16+53.1i",a.ComplexAdd(d).toString());
}
@Test
public void testComSub(){
assertEquals("1.0+i",b.ComplexSub(a).toString());
assertEquals("-21.16-54.1i",c.ComplexSub(d).toString());
assertEquals("2.0+2.0i",b.ComplexSub(c).toString());
assertEquals("-1.0-i",a.ComplexSub(b).toString());
}
@Test
public void testComMul(){
assertEquals("0.0",a.ComplexMulti(d).toString());
assertEquals("-1.0-i",b.ComplexMulti(c).toString());
assertEquals("-20.16-53.1i",c.ComplexMulti(d).toString());
assertEquals("40.32+159.3i",d.ComplexMulti(e).toString());
assertEquals("1.0+i",b.ComplexMulti(b).toString());
}
@Test
public void testComDiv(){
assertEquals("0.0",a.ComplexDiv(b).toString());
assertEquals("-1.0-i",c.ComplexDiv(b).toString());
assertEquals("-0.5-0.3333333333333333i",c.ComplexDiv(e).toString());
assertEquals("10.08+17.7i",d.ComplexDiv(e).toString());
assertEquals("20.16+53.1i",d.ComplexDiv(b).toString());
}
}
实验三 敏捷开发与XP实践 http://www.cnblogs.com/rocedu/p/4795776.html, Eclipse的内容替换成IDEA
完成重构内容的练习,下载搭档的代码,至少进行三项重构,提交重构后代码的截图,加上自己的学号水印。提交搭档的码云项目链接。
按照格式,添加作者和日期
将注释格式改为/**内容*/
将要修改的变量单击右键,Refactor->Rename
进行重命名
上传至码云
/**
* Complex class
*
* @Author 16487
* @date 2019/4/29
*/
public class lyxcomplex {
double a,b;
lyxcomplex(double m, double n){/**构造函数设置实部虚部*/
a=m;
b=n;
}
public double getRealPart(){//返回实部
return a;
}
public double getImagePart() {/**返回虚部*/
return b;
}
public lyxcomplex complexAdd(lyxcomplex y){/**加法*/
double m=y.getRealPart();
double n=y.getImagePart();
double x=a+m;
double z=b+n;
return new lyxcomplex(x,z);
}
public lyxcomplex complexSub(lyxcomplex y){/**减法*/
double m=y.getRealPart();
double n=y.getImagePart();
double x=a-m;
double z=b-n;
return new lyxcomplex(x,z);
}
public lyxcomplex complexMulti(lyxcomplex y){/**乘法*/
double m=y.getRealPart();
double n=y.getImagePart();
double x=a*m;
double z=b*n;
return new lyxcomplex(x,z);
}
public lyxcomplex complexDiv(lyxcomplex y){/**除法*/
double m=y.getRealPart();
double n=y.getImagePart();
double x=a/m;
double z=b/n;
return new lyxcomplex(x,z);
}
@Override
public java.lang.String toString() {
String s="";
if (a!=0&&b>0&&b!=1){
s+= a+"+"+ b+"i";
}
else if(a!=0&&b==1){
s+=a+"+i";
}
else if (a!=0&&b<0&&b!=-1){
s+= a+""+b+"i";
}
else if (a!=0&&b==-1){
s+=a+"-i";
}
else if (a!=0&&b==0){
s+=a;
}
else if (a==0&&b!=0){
s+=b+"i";
}
else if (a==0&&b==0){
s+="0.0";
}
return s;
}
}
/**
* Complex class
*
* @Author 16487
* @date 2019/4/29
*/
import junit.framework.TestCase;
import org.junit.Test;
public class lyxcomplexTest extends TestCase {
lyxcomplex a=new lyxcomplex(0,0);
lyxcomplex b=new lyxcomplex(1,1);
lyxcomplex c=new lyxcomplex(-1,-1);
lyxcomplex d=new lyxcomplex(20.16,53.10);
lyxcomplex e=new lyxcomplex(2,3);
@Test
public void testgetReal(){
assertEquals(0.0,a.getRealPart());
assertEquals(-1.0,c.getRealPart());
assertEquals(20.16,d.getRealPart());
}
@Test
public void testgetIma(){
assertEquals(0.0,a.getImagePart());
assertEquals(-1.0,c.getImagePart());
assertEquals(53.1,d.getImagePart());
}
@Test
public void testComAdd(){
assertEquals("0.0",b.complexAdd(c).toString());
assertEquals("1.0+i",a.complexAdd(b).toString());
assertEquals("19.16+52.1i",c.complexAdd(d).toString());
assertEquals("-1.0-i",a.complexAdd(c).toString());
assertEquals("21.16+54.1i",b.complexAdd(d).toString());
assertEquals("20.16+53.1i",a.complexAdd(d).toString());
}
@Test
public void testComSub(){
assertEquals("1.0+i",b.complexSub(a).toString());
assertEquals("-21.16-54.1i",c.complexSub(d).toString());
assertEquals("2.0+2.0i",b.complexSub(c).toString());
assertEquals("-1.0-i",a.complexSub(b).toString());
}
@Test
public void testComMul(){
assertEquals("0.0",a.complexMulti(d).toString());
assertEquals("-1.0-i",b.complexMulti(c).toString());
assertEquals("-20.16-53.1i",c.complexMulti(d).toString());
assertEquals("40.32+159.3i",d.complexMulti(e).toString());
assertEquals("1.0+i",b.complexMulti(b).toString());
}
@Test
public void testComDiv(){
assertEquals("0.0",a.complexDiv(b).toString());
assertEquals("-1.0-i",c.complexDiv(b).toString());
assertEquals("-0.5-0.3333333333333333i",c.complexDiv(e).toString());
assertEquals("10.08+17.7i",d.complexDiv(e).toString());
assertEquals("20.16+53.1i",d.complexDiv(b).toString());
}
}
code
中的功能,并掌握了几个实用的功能,步骤 | 耗时 | 百分比 |
---|---|---|
需求分析 | 20min | 10% |
设计 | 40min | 20% |
代码实现 | 50min | 25% |
测试 | 50min | 25% |
分析总结 | 40min | 20% |
2018-2019-20175334实验三《敏捷开发与XP实践》实验报告
原文:https://www.cnblogs.com/lxr1006/p/10791293.html