Browse Source

wave passed

mpierse 6 years ago
parent
commit
2c8120691b
1 changed files with 10 additions and 1 deletions
  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 View File

@@ -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
 }