瀏覽代碼

wave passed

mpierse 6 年之前
父節點
當前提交
2c8120691b
共有 1 個檔案被更改,包括 10 行新增1 行删除
  1. 10
    1
      src/main/java/rocks/zipcode/io/quiz3/arrays/WaveGenerator.java

+ 10
- 1
src/main/java/rocks/zipcode/io/quiz3/arrays/WaveGenerator.java 查看文件

@@ -1,10 +1,19 @@
1 1
 package rocks.zipcode.io.quiz3.arrays;
2 2
 
3
+import java.util.ArrayList;
4
+
3 5
 /**
4 6
  * @author leon on 09/12/2018.
5 7
  */
6 8
 public class WaveGenerator {
7 9
     public static String[] wave(String str) {
8
-        return null;
10
+        str = str.toLowerCase();
11
+        ArrayList<String> result = new ArrayList<>();
12
+        for (int i = 0; i < str.length(); i++) {
13
+            if(str.charAt(i) >= 97 && str.charAt(i) <= 122){
14
+                result.add(str.substring(0,i) + (str.substring(i,i+1).toUpperCase()) + str.substring(i+1));
15
+            }
16
+        }
17
+        return result.toArray(new String[0]);
9 18
     }
10 19
 }