|
@@ -5,10 +5,24 @@ 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
|
+ StringBuilder builder = new StringBuilder();
|
|
9
|
+ String[] strArr = str.split("");
|
|
10
|
+
|
|
11
|
+ for (int i = 0; i < strArr.length; i++) {
|
|
12
|
+ if (i == indexToCapitalize){
|
|
13
|
+ builder.append(strArr[i].toUpperCase());
|
|
14
|
+ }
|
|
15
|
+ else {
|
|
16
|
+ builder.append(strArr[i]);
|
|
17
|
+ }
|
|
18
|
+ }
|
|
19
|
+ return builder.toString();
|
9
|
20
|
}
|
10
|
21
|
|
11
|
22
|
public static Boolean isCharacterAtIndex(String baseString, Character characterToCheckFor, Integer indexOfString) {
|
12
|
|
- return null;
|
|
23
|
+ String[] strArr = baseString.split("");
|
|
24
|
+ boolean retBool = strArr[indexOfString].equalsIgnoreCase(characterToCheckFor.toString()) ? true : false;
|
|
25
|
+
|
|
26
|
+ return retBool;
|
13
|
27
|
}
|
14
|
28
|
}
|