2018-2019-20175334实验三《敏捷开发与XP实践》实验报告

一、实验内容及步骤

实验三 敏捷开发与XP实践-1

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));

}

}


- 安装alibaba插件
![](https://img2018.cnblogs.com/blog/1591528/201904/1591528-20190429162509629-843178827.png)
- 重启IDEA后,在代码中右击点击··编码规约扫描··
![](https://img2018.cnblogs.com/blog/1591528/201904/1591528-20190429162623401-1383446506.png)
- 规范后代码
```java
/**
* 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));
}
}
}
  • Code菜单中我认为好用的功能:

    • Surround With (使用if-else、for、while等语句包装代码段)) Ctrl+Alt+T

    • Comment with Line Comment ( 行注释 ) Ctrl + /

实验三 敏捷开发与XP实践-2

  • 在码云上把自己的学习搭档加入自己的项目中,确认搭档的项目加入自己后,下载搭档实验二的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实践-3

  • 实验三 敏捷开发与XP实践 http://www.cnblogs.com/rocedu/p/4795776.html, Eclipse的内容替换成IDEA

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

  • 问题一:所有的类都必须添加创建者信息

  • 按照格式,添加作者和日期

  • 问题二:类、类属性、类方法必须用javadoc规范

  • 将注释格式改为/**内容*/

  • 问题三:方法名、参数名、成员变量、局部变量没有遵从驼峰形式

  • 将要修改的变量单击右键,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());
}
}

我的代码托管

学习搭档的代码托管

实验三 敏捷开发与XP实践-4

/**
* @Author 16487
*/
import java.util.Scanner;
public class Caesar {
public String path;
public String estr="";
public char c;
public static void main(String[] args) {
Caesar c=new Caesar();
System.out.println("1.加密");
System.out.println("2.解密");
System.out.println("你要进行的操作:");
int num;
Scanner scanner=new Scanner(System.in);
num=scanner.nextInt();
System.out.println("情输入你要进行操作的字符串");
c.path=scanner.next();
int n;
Scanner scan=new Scanner(System.in);
System.out.println("情输入秘钥");
n=scan.nextInt();
if(num==1)
{
c.jiami(c.path, n);
System.out.println("加密过后的字符串为:"+c.estr);
}
else
{
c.jiemi(c.path, n);
System.out.println("解密过后的内容为:"+c.estr);
}
}
public void jiami(String key,int n)
{
for(int i=0;i<key.length();i++)
{
c=key.charAt(i);
if(c>='A'&&c<='Z')
{
if(c+n%26<='Z')
{
estr+=(char)(c+n%26);
}
else
{
estr+=(char)('A'+((n-('Z'-c)-1)%26));
}
}
else if(c>='a'&&c<='z')
{
if(c+n%26<='z')
{
estr+=(char)(c+n%26);
}
else
{
estr+=(char)('a'+((n-('z'-c)-1)%26));
}
}
else if(c>='0'&&c<='9')
{
if(c+n%10<='9')
{
estr+=(char)(c+n%10);
}
else
{
estr+=(char)('0'+((n-('9'-c)-1)%10));
}
}
else
{
estr+=c;
}
}
}
public void jiemi(String key,int n)
{
for(int i=0;i<key.length();i++)
{
c=key.charAt(i);
if(c>='A'&&c<='Z')
{
if(c-n%26>='A')
{
estr+=(char)(c-n%26);
}
else
{
estr+=(char)('Z'-((n-(c-'A')-1)%26));
}
}
else if(c>='a'&&c<='z')
{
if(c-n%26>='a')
{
estr+=(char)(c-n%26);
}
else
{
estr+=(char)('z'-((n-(c-'a')-1)%26));
}
}
else if(c>='0'&&c<='9')
{
if(c-n%10>='0')
{
estr+=(char)(c-n%10);
}
else
{
estr+=(char)('9'-((n-(c-'0')-1)%10));
}
}
else
{
estr+=c;
}
}
}
}
  • 运行结果:



二、心得体会

  • 本次实验教会了我如何写出更加规范的代码,还让我了解到了code中的功能,并掌握了几个实用的功能
  • 密码学算法部分对其他课程很有帮助
步骤 耗时 百分比
需求分析 20min 10%
设计 40min 20%
代码实现 50min 25%
测试 50min 25%
分析总结 40min 20%

2018-2019-20175334实验三《敏捷开发与XP实践》实验报告的更多相关文章

  1. 20165230 《Java程序设计》实验三 敏捷开发与XP实践 实验报告

    20165230 <Java程序设计>实验三 敏捷开发与XP实践 实验报告 一.实验报告封面 课程:Java程序设计 班级:1652班 姓名:田坤烨 学号:20165230 成绩: 指导教 ...

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

    20175212童皓桢 实验三敏捷开发与XP实践实验报告 实验内容 XP基础 XP核心实践 相关工具 实验步骤 一.Code菜单功能的研究 Move Line/statement Down/Up:将某 ...

  3. 20145308刘昊阳 《Java程序设计》实验三 敏捷开发与XP实践 实验报告

    20145308刘昊阳 <Java程序设计>实验三 敏捷开发与XP实践 实验报告 实验名称 敏捷开发与XP实践 实验内容 XP基础 XP核心实践 相关工具 统计的PSP(Personal ...

  4. 20162311 实验三 敏捷开发与XP实践 实验报告

    20162311 实验三 敏捷开发与XP实践 实验报告 实验内容 一.研究学习IDEA中的Code菜单 使用Code ->Reformate Code功能将以下代码格式化 public clas ...

  5. 20165308实验三 敏捷开发与XP实践实验报告

    实验三 敏捷开发与XP实践实验报告 实验目的 安装 alibaba 插件,解决代码中的规范问题.再研究一下Code菜单,找出一项让自己感觉最好用的功能. 在码云上把自己的学习搭档加入自己的项目中,确认 ...

  6. 20155207王雪纯 《Java程序设计》实验三 敏捷开发与XP实践 实验报告

    20155207王雪纯 <Java程序设计>实验三 敏捷开发与XP实践 实验报告 实验名称 敏捷开发与XP实践 实验内容 XP基础 XP核心实践 相关工具 统计的PSP(Personal ...

  7. 20155220 实验三 敏捷开发与XP实践 实验报告

    20155220 实验三 敏捷开发与XP实践 实验报告 实验内容 XP基础 XP核心实践 相关工具 实验要求 没有Linux基础的同学建议先学习<Linux基础入门(新版)><Vim ...

  8. # 20155224 实验三 敏捷开发与XP实践 实验报告

    20155224 实验三 敏捷开发与XP实践 实验报告 实验内容 XP基础 XP核心实践 相关工具 实验要求 没有Linux基础的同学建议先学习<Linux基础入门(新版)><Vim ...

  9. 20155226 实验三 敏捷开发与XP实践 实验报告

    20155226 实验三 敏捷开发与XP实践 实验报告 实验内容 XP基础 XP核心实践 相关工具 实验要求 没有Linux基础的同学建议先学习<Linux基础入门(新版)><Vim ...

  10. 20155311 实验三 敏捷开发与XP实践 实验报告

    20155311 实验三 敏捷开发与XP实践 实验报告 实验内容 XP基础 xp核心工具 相关工具 实验要求 没有Linux基础的同学建议先学习<Linux基础入门(新版)><Vim ...

随机推荐

  1. set类型的应用场景 —— Redis实战经验

    set类型是string类型的集合,其特点是集合元素无序且不重复,每个集合最多可以存储 232 - 1 个元素(40多亿),set类型主要有以下应用场景. 1. 好友/关注/粉丝/感兴趣的人集合 se ...

  2. Codeforces Round #616 (Div. 2) B. Array Sharpening

    t题目链接:http://codeforces.com/contest/1291/problem/B 思路: 用极端的情况去考虑问题,会变得很简单. 无论是单调递增,单调递减,或者中间高两边低的情况都 ...

  3. UnicodeDecodeError: 'gbk' codec can't decode byte 0xfe in position 45: illegal multibyte sequence

    常见的一种解码错误如题目所示,下面介绍该错误的解决方法 (1).首先在打开文本的时候,设置其编码格式,如:open(‘1.txt’, encoding=’gbk’): (2).若(1)不能解决,可能是 ...

  4. 《深入理解java虚拟机》读书笔记八——第九章

    第九章 类加载及执行子系统的案例与实战 Q:如果有10个WEB应用程序都是用Spring来进行组织管理的话,可以把Spring放到Common或Shared目录下(Tomcat5.0)让这些程序共享. ...

  5. 【C语言】输出半径1到10的圆的面积,当面积值超过100时,停止执行本程序

    #include<stdio.h> #define PI 3.142 int main() { int r; float area; ; r <= ; r++) { area = P ...

  6. jqgrid中分页和搜索,jqgrid loadonce:true后trigger("reloadGrid")无效

      第一次接触jqgrid,发现项目中好多地方都用到.   jqgrid是典型的B/S架构(浏览器/服务器模式),服务器端只需提供数据管理,浏览器只需负责数据显示.   jqGrid是用ajax实现对 ...

  7. mysql逻辑备份与还原工具mysqldump

    (一)mysqldump介绍 mysqldump是MySQL自带的逻辑备份工具,类似于Oracle的expdp/impdp,mysqldump备份十分灵活,可以在以下级别对数据库进行备份: 实例下的所 ...

  8. 【Unity|C#】番外篇(1)——6个重要概念:栈与堆,值类型与引用类型,装箱与拆箱

    传送门:https://www.cnblogs.com/arthurliu/archive/2011/04/13/2015120.html

  9. CodeForces - 645 C.Enduring Exodus

    快乐二分 用前缀和随便搞一下 #include <cstdio> using namespace std; ; int p[N]; ; inline int msum(int a, int ...

  10. Centos7 入门几个操作

    http://www.wallcopper.com/linux/1650.html 创建文件软连接 ln -s 源路径 目标路径 查看软连接ls -il 服务操作:systemctl start fo ...