码迷,mamicode.com
首页 > 编程语言 > 详细

20175333曹雅坤 实验三敏捷开发与XP实践《Java开发环境的熟悉》实验报告

时间:2019-05-03 14:25:33      阅读:138      评论:0      收藏:0      [点我收藏+]

标签:mamicode   pos   覆写   inf   href   ble   out   实验   截图   

20175333曹雅坤 实验三敏捷开发与XP实践《Java开发环境的熟悉》实验报告

敏捷开发与XP实践-1

实验目的与要求:

  • 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');
buf![](https://img2018.cnblogs.com/blog/1272669/201905/1272669-20190502160118003-975536005.png)

fer.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));
}
}

实验步骤

Settings ->Plugins -> Browse repositories...——安装alibaba。
技术图片

检查代码
技术图片

格式化之后
技术图片

  • 好用功能
    实现接口方法(Implements Methods):Ctrl + I
    Gengrate:Alt + Insert
    Surround With:Ctrl+Alt+T
    智能选择并实现(SmartType):Ctrl + Shift + 空格
    方法展开 ( Expand) Ctrl + 加号
    方法折叠 (Collapse)Ctrl + 减号
    展开Java doc注释 ( Expand doc comments )
    折叠Java doc注释 ( Collapse doc comments )
    行注释 (Comment with Line Comment )Ctrl + /
    块注释 ( Comment with Block Comment ) Ctrl + Shift + /
    格式化代码 (Reformat Code ) Ctrl + Alt + L
    重新整理代码 (Rearrange Code)

    敏捷开发与XP实践-2

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

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

    实验步骤

  • 加入仓库
    技术图片

  • 效果
    技术图片

  • 单元测试
    技术图片

  • git log
  • 代码
import java.text.DecimalFormat;
public class Complex {
    double RealPart;
    double ImagePart;
    public Complex(){

    }
    public Complex(double R,double I){
        RealPart = R;
        ImagePart = I;
    }
    public void setter(double R,double I){
        RealPart = R;
        ImagePart = I;
    }
    public double getterRealPart(){
        return RealPart;
    }
    public double getterImagePart(){
        return ImagePart;
    }
    @Override
    public boolean equals(Object obj){
        if(this==obj){
            return true;
        }
        else
        {
            return false;
        }
    }
    @Override
    public String toString(){
        String s = "";
        if(getterRealPart()==0&&getterImagePart()==0){
            s="0";
        }
        else if(getterRealPart()!=0&&getterImagePart()==0){
            s=s+getterRealPart();
        }
        else if (getterRealPart()==0&&getterImagePart()!=0){
            s=s+getterImagePart()+"i";
        }
        else
        {
            if(getterImagePart()<0){
                s = s+getterRealPart()+getterImagePart()+"i";
            }
            else {
                s = s+getterRealPart()+"+"+getterImagePart()+"i";
            }

        }
        return s;
    }
    public Complex ComplexAdd(Complex a){
        return new Complex((getterRealPart()+a.getterRealPart()),(getterImagePart()+a.getterImagePart()));
    }
    public Complex ComplexSub(Complex a){
        return new Complex((getterRealPart()-a.getterRealPart()),(getterImagePart()-a.getterImagePart()));
    }
    public Complex ComplexMulti(Complex a){
        double imaginePart = getterRealPart()*a.getterImagePart()+getterImagePart()*a.getterRealPart();
        double realPart = getterRealPart()*a.getterRealPart()-getterImagePart()*a.getterImagePart();
        return new Complex(realPart,imaginePart);
    }
    public Complex ComplexDiv(Complex a) throws Exception {
        double imaginePart = -getterRealPart()*a.getterImagePart()+getterImagePart()*a.getterRealPart();
        double realPart = getterRealPart()*a.getterRealPart()+getterImagePart()*a.getterImagePart();
        double div = a.getterRealPart()*a.getterRealPart()+a.getterImagePart()*a.getterImagePart();
        if(div==0){
            throw new Exception();
        }
        realPart = realPart/div;
        imaginePart = imaginePart/div;
        DecimalFormat decimalFormat = new DecimalFormat("0.0");
        return new Complex(Double.valueOf(decimalFormat.format(realPart)),Double.valueOf(decimalFormat.format(imaginePart)));
    }
}

敏捷开发与XP实践-3

  • http://www.cnblogs.com/rocedu/p/4795776.html, Eclipse的内容替换成IDEA
  • 完成重构内容的练习,下载搭档的代码,至少进行三项重构,提交重构后代码的截图,加上自己的学号水印。提交搭档的码云项目链接。

    实验内容及结果截图:

  • 添加创建者信息
    技术图片

  • 给覆写方法加上@Override注解
    技术图片

  • 方法名,参数名,成员变量,局部变量都统一使用lowerCamelCase,遵从驼峰形式
    技术图片

  • 规范后代码
/**
 * @author caoyakun
 * @date 2019/5/3
 */
import java.text.DecimalFormat;

public class Complex {
    double RealPart;
    double ImagePart;

    public Complex() {

    }

    public Complex(double R, double I) {
        RealPart = R;
        ImagePart = I;
    }

    public void setter(double R, double I) {
        RealPart = R;
        ImagePart = I;
    }

    public double getterRealPart() {
        return RealPart;
    }

    public double getterImagePart() {
        return ImagePart;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public String toString() {
        String s = "";
        if (getterRealPart() == 0 && getterImagePart() == 0) {
            s = "0";
        } else if (getterRealPart() != 0 && getterImagePart() == 0) {
            s = s + getterRealPart();
        } else if (getterRealPart() == 0 && getterImagePart() != 0) {
            s = s + getterImagePart() + "i";
        } else {
            if (getterImagePart() < 0) {
                s = s + getterRealPart() + getterImagePart() + "i";
            } else {
                s = s + getterRealPart() + "+" + getterImagePart() + "i";
            }

        }
        return s;
    }

    public Complex ComplexAdd(Complex a) {
        return new Complex((getterRealPart() + a.getterRealPart()), (getterImagePart() + a.getterImagePart()));
    }

    public Complex ComplexSub(Complex a) {
        return new Complex((getterRealPart() - a.getterRealPart()), (getterImagePart() - a.getterImagePart()));
    }

    public Complex ComplexMulti(Complex a) {
        double imaginePart = getterRealPart() * a.getterImagePart() + getterImagePart() * a.getterRealPart();
        double realPart = getterRealPart() * a.getterRealPart() - getterImagePart() * a.getterImagePart();
        return new Complex(realPart, imaginePart);
    }

    public Complex ComplexDiv(Complex a) throws Exception {
        double imaginePart = -getterRealPart() * a.getterImagePart() + getterImagePart() * a.getterRealPart();
        double realPart = getterRealPart() * a.getterRealPart() + getterImagePart() * a.getterImagePart();
        double div = a.getterRealPart() * a.getterRealPart() + a.getterImagePart() * a.getterImagePart();
        if (div == 0) {
            throw new Exception();
        }
        realPart = realPart / div;
        imaginePart = imaginePart / div;
        DecimalFormat decimalFormat = new DecimalFormat("0.0");
        return new Complex(Double.valueOf(decimalFormat.format(realPart)), Double.valueOf(decimalFormat.format(imaginePart)));
    }
}

码云链接

搭档
自己

20175333曹雅坤 实验三敏捷开发与XP实践《Java开发环境的熟悉》实验报告

标签:mamicode   pos   覆写   inf   href   ble   out   实验   截图   

原文地址:https://www.cnblogs.com/Hf-Hf/p/10804947.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!