Browse Source

stringCheese

Kate Moore 6 years ago
parent
commit
ae65da322e
3 changed files with 22 additions and 13 deletions
  1. BIN
      StringParser.class
  2. 19
    10
      StringParser.java
  3. 3
    3
      package.bluej

BIN
StringParser.class View File


+ 19
- 10
StringParser.java View File

@@ -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,7 +60,8 @@ public class StringParser
60 60
      * @return String
61 61
      */
62 62
     public static String upperCaseFirstCharacter(String s) {
63
-        return null;
63
+        String first = s.substring(0,1).toUpperCase() + s.substring(1).toLowerCase();
64
+        return first;
64 65
     }
65 66
 
66 67
     /**
@@ -72,7 +73,13 @@ public class StringParser
72 73
      * @return String
73 74
      */
74 75
     public static String camelCaseString(String s) {
75
-        return null;
76
+        String str = s.toLowerCase();
77
+        String first = str.split(" ") [0];
78
+        String sec = str.split(" ") [1];
79
+        String word1 = first.substring(0,1).toUpperCase() + first.substring(1).toLowerCase();
80
+        String word2 = sec.substring(0,1).toUpperCase() + sec.substring(1).toLowerCase();
81
+        String totalstr = word1 + word2;
82
+        return totalstr;
76 83
     }
77 84
 
78 85
     /**
@@ -84,7 +91,8 @@ public class StringParser
84 91
      * @return String
85 92
      */
86 93
     public static String snakeCaseString(String s) {
87
-        return null;
94
+        
95
+        return s.toLowerCase().replace(' ', '_');
88 96
     }
89 97
 
90 98
     /**
@@ -95,7 +103,7 @@ public class StringParser
95 103
      * @return String
96 104
      */
97 105
     public static Integer getLength(String s) {
98
-        return null;
106
+        return s.length();
99 107
     }
100 108
 
101 109
     /**
@@ -109,7 +117,8 @@ public class StringParser
109 117
      * @return String
110 118
      */
111 119
     public static Boolean isEqual(String s1, String s2) {
112
-        return null;
120
+        
121
+        return s1.equals(s2);
113 122
     }
114 123
 
115 124
     /**
@@ -123,6 +132,6 @@ public class StringParser
123 132
      * @return String
124 133
      */
125 134
     public static Boolean isEqualIgnoreCase(String s1, String s2) {
126
-        return null;
135
+        return s1.equalsIgnoreCase(s2);
127 136
     }
128 137
 }

+ 3
- 3
package.bluej View File

@@ -3,9 +3,9 @@ dependency1.from=StringParserTest
3 3
 dependency1.to=StringParser
4 4
 dependency1.type=UsesDependency
5 5
 editor.fx.0.height=722
6
-editor.fx.0.width=800
7
-editor.fx.0.x=455
8
-editor.fx.0.y=51
6
+editor.fx.0.width=1030
7
+editor.fx.0.x=179
8
+editor.fx.0.y=23
9 9
 objectbench.height=164
10 10
 objectbench.width=776
11 11
 package.divider.horizontal=0.6