|
@@ -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,7 @@ public class StringParser
|
49
|
49
|
* @return String
|
50
|
50
|
*/
|
51
|
51
|
public static Character getNthCharacter(String s, Integer n) {
|
52
|
|
- return null;
|
|
52
|
+ return s.charAt(n);
|
53
|
53
|
}
|
54
|
54
|
|
55
|
55
|
/**
|
|
@@ -60,10 +60,13 @@ public class StringParser
|
60
|
60
|
* @return String
|
61
|
61
|
*/
|
62
|
62
|
public static String upperCaseFirstCharacter(String s) {
|
63
|
|
- return null;
|
|
63
|
+ String str = s;
|
|
64
|
+ String cap = str.substring(0,1).toUpperCase() + str.substring(1);
|
|
65
|
+ return cap;
|
|
66
|
+
|
64
|
67
|
}
|
65
|
68
|
|
66
|
|
- /**
|
|
69
|
+ /** NEED TO FINISH
|
67
|
70
|
* Takes a String and returns that string with the first character of each word in it uppercased
|
68
|
71
|
* and then joined.
|
69
|
72
|
* E.G. dog whistle would return DogWhistle. adjuNCT pRoFessOR would return AdjuctProfessor.
|
|
@@ -72,7 +75,19 @@ public class StringParser
|
72
|
75
|
* @return String
|
73
|
76
|
*/
|
74
|
77
|
public static String camelCaseString(String s) {
|
75
|
|
- return null;
|
|
78
|
+ String lower = s.toLowerCase();
|
|
79
|
+ String first = " ";
|
|
80
|
+ for (int i = 0; i < lower.length(); i++) {
|
|
81
|
+ if (Character.isWhitespace(lower.charAt(i))) {
|
|
82
|
+ first = lower.substring(0,i);
|
|
83
|
+ break;
|
|
84
|
+ }
|
|
85
|
+ }
|
|
86
|
+ first = first.substring(0,1).toUpperCase() + first.substring(1);
|
|
87
|
+ String second = lower.substring(first.length()+1);
|
|
88
|
+ second = second.substring(0,1).toUpperCase() + second.substring(1);
|
|
89
|
+ String cC = first + second;
|
|
90
|
+ return cC;
|
76
|
91
|
}
|
77
|
92
|
|
78
|
93
|
/**
|
|
@@ -84,7 +99,13 @@ public class StringParser
|
84
|
99
|
* @return String
|
85
|
100
|
*/
|
86
|
101
|
public static String snakeCaseString(String s) {
|
87
|
|
- return null;
|
|
102
|
+
|
|
103
|
+ String itemname = s;
|
|
104
|
+ itemname = itemname.replaceAll(" ","_").toLowerCase();
|
|
105
|
+ String finale = itemname;
|
|
106
|
+ System.out.print(finale);
|
|
107
|
+ return finale;
|
|
108
|
+
|
88
|
109
|
}
|
89
|
110
|
|
90
|
111
|
/**
|
|
@@ -95,7 +116,7 @@ public class StringParser
|
95
|
116
|
* @return String
|
96
|
117
|
*/
|
97
|
118
|
public static Integer getLength(String s) {
|
98
|
|
- return null;
|
|
119
|
+ return s.length();
|
99
|
120
|
}
|
100
|
121
|
|
101
|
122
|
/**
|
|
@@ -109,7 +130,11 @@ public class StringParser
|
109
|
130
|
* @return String
|
110
|
131
|
*/
|
111
|
132
|
public static Boolean isEqual(String s1, String s2) {
|
112
|
|
- return null;
|
|
133
|
+ if (s1 == s2) {
|
|
134
|
+ return true;
|
|
135
|
+ } else {
|
|
136
|
+ return false;
|
|
137
|
+ }
|
113
|
138
|
}
|
114
|
139
|
|
115
|
140
|
/**
|
|
@@ -123,6 +148,13 @@ public class StringParser
|
123
|
148
|
* @return String
|
124
|
149
|
*/
|
125
|
150
|
public static Boolean isEqualIgnoreCase(String s1, String s2) {
|
126
|
|
- return null;
|
|
151
|
+
|
|
152
|
+ if (s1.equalsIgnoreCase(s2)) {
|
|
153
|
+ return true;
|
|
154
|
+ } else {
|
|
155
|
+ return false;
|
|
156
|
+ }
|
|
157
|
+
|
127
|
158
|
}
|
|
159
|
+
|
128
|
160
|
}
|