|
|
@@ -15,7 +15,7 @@ public class StringParser
|
|
15
|
15
|
*/
|
|
16
|
16
|
public static String upperCaseString(String s)
|
|
17
|
17
|
{
|
|
18
|
|
- return null;
|
|
|
18
|
+ return s.toUpperCase();
|
|
19
|
19
|
}
|
|
20
|
20
|
|
|
21
|
21
|
/**
|
|
|
@@ -26,7 +26,7 @@ public class StringParser
|
|
26
|
26
|
* @return String
|
|
27
|
27
|
*/
|
|
28
|
28
|
public static String lowerCaseString(String s) {
|
|
29
|
|
- return null;
|
|
|
29
|
+ return s.toLowerCase();
|
|
30
|
30
|
}
|
|
31
|
31
|
|
|
32
|
32
|
/**
|
|
|
@@ -37,7 +37,7 @@ public class StringParser
|
|
37
|
37
|
* @return String
|
|
38
|
38
|
*/
|
|
39
|
39
|
public static Character getFirstCharacter(String s) {
|
|
40
|
|
- return null;
|
|
|
40
|
+ return s.charAt(0);
|
|
41
|
41
|
}
|
|
42
|
42
|
|
|
43
|
43
|
/**
|
|
|
@@ -49,7 +49,10 @@ public class StringParser
|
|
49
|
49
|
* @return String
|
|
50
|
50
|
*/
|
|
51
|
51
|
public static Character getNthCharacter(String s, Integer n) {
|
|
52
|
|
- return null;
|
|
|
52
|
+
|
|
|
53
|
+ char c = s.charAt(n);
|
|
|
54
|
+
|
|
|
55
|
+ return c;
|
|
53
|
56
|
}
|
|
54
|
57
|
|
|
55
|
58
|
/**
|
|
|
@@ -60,7 +63,14 @@ public class StringParser
|
|
60
|
63
|
* @return String
|
|
61
|
64
|
*/
|
|
62
|
65
|
public static String upperCaseFirstCharacter(String s) {
|
|
63
|
|
- return null;
|
|
|
66
|
+ // substring has a beginning index and end index
|
|
|
67
|
+ // if one doesn't put the end index it'll return the rest of the words
|
|
|
68
|
+ // after the beginning index. Else it'll just return 1 character in thid
|
|
|
69
|
+ // exercise.
|
|
|
70
|
+
|
|
|
71
|
+ String c = s.substring(0,1).toUpperCase() + s.substring(1);
|
|
|
72
|
+ return c;
|
|
|
73
|
+
|
|
64
|
74
|
}
|
|
65
|
75
|
|
|
66
|
76
|
/**
|
|
|
@@ -72,7 +82,17 @@ public class StringParser
|
|
72
|
82
|
* @return String
|
|
73
|
83
|
*/
|
|
74
|
84
|
public static String camelCaseString(String s) {
|
|
75
|
|
- return null;
|
|
|
85
|
+ String c = s.toLowerCase();
|
|
|
86
|
+ String x1 = c.split(" ")[0];
|
|
|
87
|
+ String x2 = c.split(" ")[1];
|
|
|
88
|
+ String container = x1.substring(0,1).toUpperCase() + x1.substring(1);
|
|
|
89
|
+ String container1 = x2.substring(0,1).toUpperCase() + x2.substring(1);
|
|
|
90
|
+ String putittogether = container + container1;
|
|
|
91
|
+
|
|
|
92
|
+ return putittogether.trim();
|
|
|
93
|
+
|
|
|
94
|
+
|
|
|
95
|
+
|
|
76
|
96
|
}
|
|
77
|
97
|
|
|
78
|
98
|
/**
|
|
|
@@ -84,7 +104,9 @@ public class StringParser
|
|
84
|
104
|
* @return String
|
|
85
|
105
|
*/
|
|
86
|
106
|
public static String snakeCaseString(String s) {
|
|
87
|
|
- return null;
|
|
|
107
|
+ String c = s.replace(" ","_");
|
|
|
108
|
+
|
|
|
109
|
+ return c.toLowerCase();
|
|
88
|
110
|
}
|
|
89
|
111
|
|
|
90
|
112
|
/**
|
|
|
@@ -95,7 +117,8 @@ public class StringParser
|
|
95
|
117
|
* @return String
|
|
96
|
118
|
*/
|
|
97
|
119
|
public static Integer getLength(String s) {
|
|
98
|
|
- return null;
|
|
|
120
|
+ int c = s.length();
|
|
|
121
|
+ return c;
|
|
99
|
122
|
}
|
|
100
|
123
|
|
|
101
|
124
|
/**
|
|
|
@@ -109,7 +132,11 @@ public class StringParser
|
|
109
|
132
|
* @return String
|
|
110
|
133
|
*/
|
|
111
|
134
|
public static Boolean isEqual(String s1, String s2) {
|
|
112
|
|
- return null;
|
|
|
135
|
+ if (s1.equals(s2)){
|
|
|
136
|
+ return true;
|
|
|
137
|
+
|
|
|
138
|
+ }
|
|
|
139
|
+ return false;
|
|
113
|
140
|
}
|
|
114
|
141
|
|
|
115
|
142
|
/**
|
|
|
@@ -118,11 +145,15 @@ public class StringParser
|
|
118
|
145
|
* cat and CaT would return true.
|
|
119
|
146
|
* Dog and Dog would return true
|
|
120
|
147
|
*
|
|
121
|
|
- * @param s1
|
|
|
148
|
+ * @param s1)
|
|
122
|
149
|
* @param s2
|
|
123
|
150
|
* @return String
|
|
124
|
151
|
*/
|
|
125
|
152
|
public static Boolean isEqualIgnoreCase(String s1, String s2) {
|
|
126
|
|
- return null;
|
|
|
153
|
+ if(s1.equalsIgnoreCase(s2)){
|
|
|
154
|
+ return true;
|
|
|
155
|
+
|
|
|
156
|
+ }
|
|
|
157
|
+ return false;
|
|
127
|
158
|
}
|
|
128
|
159
|
}
|