|
@@ -15,7 +15,8 @@ public class StringParser
|
15
|
15
|
*/
|
16
|
16
|
public static String upperCaseString(String s)
|
17
|
17
|
{
|
18
|
|
- return null;
|
|
18
|
+
|
|
19
|
+ return s.toUpperCase();
|
19
|
20
|
}
|
20
|
21
|
|
21
|
22
|
/**
|
|
@@ -26,7 +27,8 @@ public class StringParser
|
26
|
27
|
* @return String
|
27
|
28
|
*/
|
28
|
29
|
public static String lowerCaseString(String s) {
|
29
|
|
- return null;
|
|
30
|
+
|
|
31
|
+ return s.toLowerCase();
|
30
|
32
|
}
|
31
|
33
|
|
32
|
34
|
/**
|
|
@@ -37,7 +39,8 @@ public class StringParser
|
37
|
39
|
* @return String
|
38
|
40
|
*/
|
39
|
41
|
public static Character getFirstCharacter(String s) {
|
40
|
|
- return null;
|
|
42
|
+
|
|
43
|
+ return s.charAt(0);
|
41
|
44
|
}
|
42
|
45
|
|
43
|
46
|
/**
|
|
@@ -49,7 +52,7 @@ public class StringParser
|
49
|
52
|
* @return String
|
50
|
53
|
*/
|
51
|
54
|
public static Character getNthCharacter(String s, Integer n) {
|
52
|
|
- return null;
|
|
55
|
+ return s.charAt(n);
|
53
|
56
|
}
|
54
|
57
|
|
55
|
58
|
/**
|
|
@@ -60,7 +63,7 @@ public class StringParser
|
60
|
63
|
* @return String
|
61
|
64
|
*/
|
62
|
65
|
public static String upperCaseFirstCharacter(String s) {
|
63
|
|
- return null;
|
|
66
|
+ return s = Character.toUpperCase(s.charAt(0)) + s.substring(1);
|
64
|
67
|
}
|
65
|
68
|
|
66
|
69
|
/**
|
|
@@ -72,19 +75,27 @@ public class StringParser
|
72
|
75
|
* @return String
|
73
|
76
|
*/
|
74
|
77
|
public static String camelCaseString(String s) {
|
75
|
|
- return null;
|
|
78
|
+
|
|
79
|
+ String camalCase2 = "";
|
|
80
|
+ String camalCase3 = s.toLowerCase();
|
|
81
|
+ String[] camalCase = camalCase3.split(" ");
|
|
82
|
+ for(int i = 0; i < camalCase.length; i++){
|
|
83
|
+ camalCase2 += camalCase[i].substring(0,1).toUpperCase();
|
|
84
|
+ camalCase2 += camalCase[i].substring(1);
|
|
85
|
+ }
|
|
86
|
+ return camalCase2;
|
76
|
87
|
}
|
77
|
88
|
|
78
|
89
|
/**
|
79
|
90
|
* Takes a String and returns that string with each character lowercased
|
80
|
91
|
* and then joined with an underscore
|
81
|
|
- * E.G. dog whistle would return dog_whistle. adjuNCT pRoFessOR would return adjuct_professor.
|
|
92
|
+ * E.G. "dog whistle" would return dog_whistle. adjuNCT pRoFessOR would return adjuct_professor.
|
82
|
93
|
*
|
83
|
94
|
* @param s
|
84
|
95
|
* @return String
|
85
|
96
|
*/
|
86
|
97
|
public static String snakeCaseString(String s) {
|
87
|
|
- return null;
|
|
98
|
+ return s.replace(" ","_").toLowerCase();
|
88
|
99
|
}
|
89
|
100
|
|
90
|
101
|
/**
|
|
@@ -95,7 +106,7 @@ public class StringParser
|
95
|
106
|
* @return String
|
96
|
107
|
*/
|
97
|
108
|
public static Integer getLength(String s) {
|
98
|
|
- return null;
|
|
109
|
+ return s.length();
|
99
|
110
|
}
|
100
|
111
|
|
101
|
112
|
/**
|
|
@@ -109,7 +120,7 @@ public class StringParser
|
109
|
120
|
* @return String
|
110
|
121
|
*/
|
111
|
122
|
public static Boolean isEqual(String s1, String s2) {
|
112
|
|
- return null;
|
|
123
|
+ return s1.equals(s2);
|
113
|
124
|
}
|
114
|
125
|
|
115
|
126
|
/**
|
|
@@ -123,6 +134,6 @@ public class StringParser
|
123
|
134
|
* @return String
|
124
|
135
|
*/
|
125
|
136
|
public static Boolean isEqualIgnoreCase(String s1, String s2) {
|
126
|
|
- return null;
|
|
137
|
+ return s1.equalsIgnoreCase(s2);
|
127
|
138
|
}
|
128
|
139
|
}
|