20165321 Experiment 3 Agile Development and XP Practice

Task 1:

Require:

  Refer to http://www.cnblogs.com/rocedu/p/6371315.html#SECCODESTANDARD to install the alibaba plugin to solve the specification problem in the code.
  Use the tool (Code->Reformate Code) in IDEA to reformat the following code, and then study the Code menu to find a function that makes you feel the best. Submit a screenshot and add your student ID watermark.
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.
}
}

screenshot:




Task 2:

Require:

  Add your learning partner to your own project on the code cloud. After confirming that the partner's project is added to yourself, download the Complex code of partner experiment 2, add no less than three JUnit unit test cases, and git add .; git after the test is successful commit -m "Add content to your student number"; git push;
  submit a screenshot of the git log of the partner project, including the above git commit information, and add your own student number watermark information.

screenshot:


Task 3:

Require:

  Complete the refactoring exercises, download your partner's code, perform at least three refactorings, submit a screenshot of the refactored code, and add your own student ID watermark. Submit your partner's code cloud project link.

answer:

Refactoring of class names

Since there is no need to encapsulate in the code, the Encapsulate Field in Refactor... is displayed in a gray state that cannot be clicked.

Partner Code Cloud Project Link

java-besti-is-hcj

Task 4:

Require:

  Refer to http://www.cnblogs.com/rocedu/p/6683948.html to complete the learning of Java cryptography related content in pairs, combining refactoring, git, and code standards .
  Submit the learning outcome code cloud link and representative results screenshots, with a student ID watermark.

answer:

Java Cryptography Program

import java.util.*;
public class Lfsr {
    public static void main(String[] args) {
        System.out.println("请输入移位寄存器的级数n:");
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        System.out.println("请设置初态:");
        int[] a = new int[n];//状态数
        int  sum=1;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            sum=2*sum;
        }
        System.out.println("请输入结构常数:");//形如[c1,c2,c3,c4,c5]
        int[] c = new int[n];//存储的为反馈函数,与反馈函数的对应规律为:若结构常数为[0,1,0,1],则反馈函数为
        for (int i = n-1; i >= 0; i--) {
            c[i] = sc.nextInt();
        }
        System.out.println("线性移位寄存器输出序列为:");
        for (int i = 0; i <sum-1; i++) {
            System.out.printf("%d", a[0]);
            operate1(a, c, n);
        }
        System.out.println(" ");
        System.out.println("对偶移位寄存器输出序列为:");
        for(int i=0;i<sum-1;i++) {
            System.out.printf("%d",a[0]);
            operate2(a,c,n);
        }
    }
    private static int[] operate2(int[] a, int[] c, int n) {
        int temp=a[0];
        for(int i=0;i<n-1;i++) {
            a[i]=a[i+1];
        }
        a[n-1]=0;
        if(temp==1) {
            for(int j=0;j<n;j++) {
                a[j]=(a[j]+c[n-j-1])%2;
            }
        }
        return a;
    }
    private static int[] operate1(int[] a, int[] c, int n) {
        int temp=0;
        for (int i = 0; i < n; i++) {
            if (a[i] * c[i] == 1) {
                temp += 1;
            }
        }
        a[n - 1] %= 2;
        for (int j = 0; j < n - 1; j++) {
            a[j] = a[j + 1];
        }
        a[n-1]=temp;
        return a;
    }
}

screenshot


Experimental impression

  In this experiment, my partner and I completed the first three tasks separately, and then worked together to conquer the last task. I think as long as two people work together, the more difficult tasks can be completed.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324974271&siteId=291194637