Nuridalia.Hernandez 6 år sedan
förälder
incheckning
89ec8c2268

+ 14
- 3
src/main/java/rocks/zipcode/io/quiz3/fundamentals/StringUtils.java Visa fil

@@ -5,10 +5,21 @@ package rocks.zipcode.io.quiz3.fundamentals;
5 5
  */
6 6
 public class StringUtils {
7 7
     public static String capitalizeNthCharacter(String str, Integer indexToCapitalize) {
8
-        return null;
8
+
9
+        return  str.substring(indexToCapitalize).toUpperCase();
10
+
9 11
     }
10 12
 
11 13
     public static Boolean isCharacterAtIndex(String baseString, Character characterToCheckFor, Integer indexOfString) {
12
-        return null;
13
-    }
14
+
15
+         char [] chars = baseString.toCharArray();
16
+        for (int i = 0; i <chars.length ; i++) {
17
+
18
+            if (chars[indexOfString] == characterToCheckFor) {
19
+                return true;
20
+            }
21
+        }
22
+
23
+            return false;
24
+        }
14 25
 }

+ 25
- 1
src/main/java/rocks/zipcode/io/quiz3/generics/ArrayUtility.java Visa fil

@@ -12,19 +12,43 @@ public class ArrayUtility<SomeType> {
12 12
         this.array = array;
13 13
     }
14 14
 
15
+
16
+
17
+
18
+
15 19
     public SomeType findOddOccurringValue() {
20
+
21
+
22
+
23
+
24
+
25
+
26
+
16 27
         return null;
17 28
     }
18 29
 
19 30
     public SomeType findEvenOccurringValue() {
31
+
20 32
         return null;
21 33
     }
22 34
 
23 35
     public Integer getNumberOfOccurrences(SomeType valueToEvaluate) {
24
-        return null;
36
+        Integer count = 0;
37
+
38
+        for (int i = 0; i <array.length ; i++) {
39
+            if( array [i]  == valueToEvaluate){
40
+                 count ++;
41
+            }
42
+
43
+
44
+        }
45
+
46
+
47
+        return count;
25 48
     }
26 49
 
27 50
     public SomeType[] filter(Function<SomeType, Boolean> predicate) {
51
+
28 52
         return null;
29 53
     }
30 54
 }