20165333 Experiment 3 Agile Development and XP Practice

Experimental content

1. Refer to http://www.cnblogs.com/rocedu/p/6371315.html#SECCODESTANDARD to install the alibaba plug-in 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.
Before code specification

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

After specification

2. Add your learning partner to your own project on the code cloud. After confirming that the partner's project has been added to your own, download the Complex code of partner experiment 2, add no less than three JUnit unit test cases, and git add . ; git commit -m "Add content to your student number"; git push;

Submit a screenshot of the partner project git log, including the above git commit information, and add your own student number watermark information.
code show as below

 class Complex {
     private double r;
     private double i;

     public Complex(double r, double i) {
         this.r = r;
         this.i = i;
     }
     public static double getRealPart(double r) {
         return r;
     }
     public static double getImagePart(double i) {
         return i;
     }

     public Complex ComplexAdd(Complex a) {
         return new Complex(r + a.r, i + a.i);
     }

     public Complex ComplexSub(Complex a) {
         return new Complex(r - a.r, i - a.i);
     }
     public Complex ComplexMulti(Complex a) {
         return new Complex(r * a.r - i * a.i , r * a.i + i * a.r);
     }
     public Complex ComplexDiv(Complex a) {
         return new Complex((r * a.i + i * a.r) / (a.i * a.i + a.r * a.r), (i * a.i + r * a.r) / (a.i * a.i + a.r * a.r));
     }
     public String toString() {
         String s =" ";
         if (i > 0)
             s =r +"+"+ i +"i";
         if (i == 0)
             s =r+"";
         if (i < 0)
             s = r +" "+ i+"i";
         return s;
     }
 }



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

experimental feeling

Through this experiment, I once again experienced the power of a team, the spark of thinking collision, and paired learning improves the learning efficiency.

Guess you like

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