日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

20175212童皓桢 实验三敏捷开发与XP实践实验报告

發(fā)布時間:2024/1/8 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 20175212童皓桢 实验三敏捷开发与XP实践实验报告 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

20175212童皓楨 實驗三敏捷開發(fā)與XP實踐實驗報告

實驗內容

  • XP基礎
  • XP核心實踐
  • 相關工具

    實驗步驟

    一、Code菜單功能的研究

  • Move Line/statement Down/Up:將某行、表達式向下、向上移動一行
  • suround with:用 try-catch,for,if等包裹語句
  • comment with line/block comment:把選中它區(qū)域變成注釋
  • show reformat file dialog:按照格式自動對齊
  • Optimize imports:可以優(yōu)化imports,去除不必要的imports
  • Insert Live Template:插入一些記不起來的 Live Template 縮寫

二、下載搭檔的Complex代碼并添加單元測試

1.添加搭檔倉庫

2.產品代碼

/*** @author Jason Tong* @date 2019/4/29 14:32.*/ public class Complex {// 定義屬性并生成getter,setterdouble RealPart;double ImagePart;// 定義構造函數public Complex(){}public Complex(double R,double I){ImagePart = I;RealPart = R;}public boolean equals(Object obj){if(this == obj) {return true;}if(!(obj instanceof Complex)) {return false;}Complex complex = (Complex) obj;if(complex.RealPart != ((Complex) obj).RealPart) {return false;}if(complex.ImagePart != ((Complex) obj).ImagePart) {return false;}return true;}public String toString() {String str = "";if (ImagePart > 0)str = RealPart + "+" + ImagePart + "i";if (ImagePart == 0)str = RealPart + "";if (ImagePart < 0)str = RealPart + " " + ImagePart + "i";return str;}// 定義公有方法:加減乘除Complex ComplexAdd(Complex a) {return new Complex(RealPart+a.RealPart,ImagePart+a.ImagePart);}Complex ComplexSub(Complex a) {return new Complex(RealPart-a.RealPart,ImagePart-a.ImagePart);}Complex ComplexMulti(Complex a) {return new Complex(RealPart*a.RealPart,ImagePart*a.ImagePart);}Complex ComplexDiv(Complex a) {if(a.RealPart==0||a.ImagePart==0) {System.out.println("被減數不能為0");return new Complex();}double d = Math.sqrt(a.RealPart*a.RealPart)+Math.sqrt(a.ImagePart*a.ImagePart);return new Complex((RealPart*a.RealPart+ImagePart*a.ImagePart)/d,Math.round((RealPart*a.ImagePart-ImagePart*a.RealPart)/d));} }

3.測試代碼

import static org.junit.Assert.*; import org.junit.Test; import junit.framework.TestCase;public class ComplexTest extends TestCase {Complex complex = new Complex(1,1);@Testpublic void testAdd(){assertEquals(new Complex(4.3,4.4), complex.ComplexAdd(new Complex(3.3,3.4)));}//測試加法@Testpublic void testSub(){assertEquals(new Complex(-4.3,-3.4), complex.ComplexSub(new Complex(5.3,4.4)));}//測試減法@Testpublic void testMulti(){assertEquals(new Complex(4.0,3.0), complex.ComplexMulti(new Complex(4.0,3.0)));}//測試乘法@Testpublic void testDiv(){assertEquals(new Complex(1.0,1.0), complex.ComplexDiv(new Complex(1.0,1.0)));assertEquals(new Complex(0.0,0.0), complex.ComplexDiv(new Complex(1.0,0.0)));//assertEquals(new Complex(0.0,0.0), complex.ComplexDiv(new Complex(3,4)));//邊緣測試}@Testpublic void testequals(){assertEquals(true, complex.equals(new Complex(1.0,1.0)));}//測試判斷相等 }

三、重構的練習

原代碼為:


class A {final double PI=3.1415926;// PI是常量public double getArea(final double r) {return PI*r*r;}public final void speak() {System.out.println("您好,How's everything here ?");} } public class Example5_9 {public static void main(String args[]) {A a=new A();System.out.println("面積:"+a.getArea(100));a.speak(); } }

對類名以及變量名進行重構

進行封裝

重構后的代碼為:

/*** @author Jason Tong* @date 2019/4/29 16:53.*/ class Calculate {final double PI=3.1415926;// PI是常量private int r;public double getArea() {return PI* getR() * getR();}public final void speak() {System.out.println("您好,How's everything here ?");}public int getR() {return r;}public void setR(int r) {this.r = r;} } public class Example5_9 {public static void main(String args[]) {Calculate a=new Calculate();a.setR(10);System.out.println("面積:"+a.getArea());a.speak();} }

四、用Java完成密碼學內容

用java實現凱撒密碼
代碼為:

/*** @author Jason Tong* @date 2019/5/3 16:58.*/ public class Caesar {public static void main(String args[]) throws Exception{String s=args[0];int key=Integer.parseInt(args[1]);Movement m=new Movement();int n=s.length();String es="";for(int i=0;i<s.length();i++){char c=s.charAt(i);if(c >= 'a' && c <= 'z'){es=m.realizeMove(n,c,key,'a','z');}else if (c >= 'A' && c <= 'Z'){es=m.realizeMove(n,c,key,'A','Z');}}System.out.println(es);} } /*** @author Jason Tong* @date 2019/5/3 16:59.*/ public class Movement {String es="";public String realizeMove(int n,char c,int key,char a,char b){//移動key%26位c+=key%26;if(c<a) {c+=26;//向左超界}if(c>b) {c-=26;//向右超界}es+=c;return es;} }

實驗中遇到的問題

  • 問題一:使用alibaba插件檢查代碼規(guī)范性,提示缺少開發(fā)者信息
  • 解決辦法一:File>Setting>Editor>File and Code Template按照下圖輸入開發(fā)者信息,新建類時自動添加信息。

完成代碼規(guī)范

  • 問題二:無法推送搭檔的倉庫
  • 解決辦法二: 根據命令行提示,表明身份信息,即可推送

    感悟和體會

  • 學會使用Java作為工具,幫助其他學科的學習,比如密碼學或是數據結構
  • 可以在倉庫中添加其他成員,以便于將來的結對和團隊學習
  • 血淚教訓!!! 修改博客隨筆時一定要及時備份!!經常記得git pull!!!

參考博客

https://blog.csdn.net/weixin_42254058/article/details/81219931

http://www.cnblogs.com/rocedu/p/4795776.html

轉載于:https://www.cnblogs.com/thz666/p/10805714.html

總結

以上是生活随笔為你收集整理的20175212童皓桢 实验三敏捷开发与XP实践实验报告的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。