|
@@ -5,7 +5,7 @@ package rocks.zipcode.quiz5.fundamentals;
|
5
|
5
|
*/
|
6
|
6
|
public class StringUtils {
|
7
|
7
|
public static Character getMiddleCharacter(String string) {
|
8
|
|
- return null;
|
|
8
|
+ return string.charAt(string.length()/2);
|
9
|
9
|
}
|
10
|
10
|
|
11
|
11
|
public static String capitalizeMiddleCharacter(String str) {
|
|
@@ -17,15 +17,35 @@ public class StringUtils {
|
17
|
17
|
}
|
18
|
18
|
|
19
|
19
|
public static Boolean isIsogram(String str) {
|
20
|
|
- return null;
|
|
20
|
+ for(int i = 0; i < str.length(); i++){
|
|
21
|
+ for (int j = i+1; j < str.length(); j++){
|
|
22
|
+ if (str.charAt(i) == str.charAt(j)){
|
|
23
|
+ return false;
|
|
24
|
+ }
|
|
25
|
+ }
|
|
26
|
+ }
|
|
27
|
+
|
|
28
|
+ return true;
|
21
|
29
|
}
|
22
|
30
|
|
23
|
31
|
public static Boolean hasDuplicateConsecutiveCharacters(String str) {
|
24
|
|
- return null;
|
|
32
|
+ for(int i = 0; i < str.length()-1; i++){
|
|
33
|
+ if(str.charAt(i) == str.charAt(i +1)){
|
|
34
|
+ return true;
|
|
35
|
+ }
|
|
36
|
+ }
|
|
37
|
+ return false;
|
25
|
38
|
}
|
26
|
39
|
|
27
|
40
|
public static String removeConsecutiveDuplicateCharacters(String str) {
|
28
|
|
- return null;
|
|
41
|
+ String nString = new String();
|
|
42
|
+ int index = 0;
|
|
43
|
+ for (int i = 0; i < str.length(); i++){
|
|
44
|
+ char c = str.charAt(i);
|
|
45
|
+ nString += c;
|
|
46
|
+ }
|
|
47
|
+
|
|
48
|
+ return nString;
|
29
|
49
|
}
|
30
|
50
|
|
31
|
51
|
public static String invertCasing(String str) {
|