1)把一個英語句子中的單詞次序顛倒後輸出。例如輸入「how are you」,輸出「you are how」; (2)編寫單元測試進行測試; (3)用ElcEmma查看代碼覆蓋率,要求覆蓋率達到100

package two;java

 

import java.util.Scanner;app

 

public class TestTwo {spa

   

 

 

    public static void Testtwo(String str) {it

        // TODO Auto-generated method stubio

       

   

       

       

        String[] strArr = str.split("\\s+|[,]");class

        StringBuffer result = new StringBuffer();test

        for(int i = strArr.length -1;i >=0; i--){import

        result.append(strArr[i] + " ");im

        }static

        result.setCharAt(str.length()-0, (char) 0);

        System.out.println("顛倒順序後的結果爲:"+result.toString());

        }

        }

 

 

package two;

 

import static org.junit.Assert.*;

 

 

 

 

import org.junit.Test;

 

public class TestTwoTest {

 

    @Test

    public void test() {

       

        String str = "how are you";

        TestTwo.Testtwo(str);

    }

 

}

相關文章
相關標籤/搜索