Browse Source

changed code to pass all tests

Akeem Cherry 6 years ago
parent
commit
d2c1899052
3 changed files with 16 additions and 12 deletions
  1. BIN
      StringParser.class
  2. 14
    10
      StringParser.java
  3. 2
    2
      package.bluej

BIN
StringParser.class View File


+ 14
- 10
StringParser.java View File

@@ -15,7 +15,8 @@ public class StringParser
15 15
      */
16 16
     public static String upperCaseString(String s)
17 17
     {
18
-        return null;
18
+        String str = "";
19
+        return s.toUpperCase();
19 20
     }
20 21
 
21 22
     /**
@@ -26,7 +27,7 @@ public class StringParser
26 27
      * @return String
27 28
      */
28 29
     public static String lowerCaseString(String s) {
29
-        return null;
30
+        return s.toLowerCase();
30 31
     }
31 32
 
32 33
     /**
@@ -37,7 +38,7 @@ public class StringParser
37 38
      * @return String
38 39
      */
39 40
     public static Character getFirstCharacter(String s) {
40
-        return null;
41
+        return s.charAt(0);
41 42
     }
42 43
 
43 44
     /**
@@ -49,7 +50,7 @@ public class StringParser
49 50
      * @return String
50 51
      */
51 52
     public static Character getNthCharacter(String s, Integer n) {
52
-        return null;
53
+        return s.charAt(n);
53 54
     }
54 55
 
55 56
     /**
@@ -60,7 +61,7 @@ public class StringParser
60 61
      * @return String
61 62
      */
62 63
     public static String upperCaseFirstCharacter(String s) {
63
-        return null;
64
+        return s.substring(0,1).toUpperCase()+s.substring(1);
64 65
     }
65 66
 
66 67
     /**
@@ -72,7 +73,8 @@ public class StringParser
72 73
      * @return String
73 74
      */
74 75
     public static String camelCaseString(String s) {
75
-        return null;
76
+        int x = s.indexOf(' ');
77
+        return s.substring(0,1).toUpperCase() + s.substring(1,x).toLowerCase() + s.substring(x+1,x+2).toUpperCase() + s.substring(x+2).toLowerCase();
76 78
     }
77 79
 
78 80
     /**
@@ -84,7 +86,8 @@ public class StringParser
84 86
      * @return String
85 87
      */
86 88
     public static String snakeCaseString(String s) {
87
-        return null;
89
+        int x = s.indexOf(' ');
90
+        return s.substring(0,x).toLowerCase() + "_" + s.substring(x+1).toLowerCase();
88 91
     }
89 92
 
90 93
     /**
@@ -95,7 +98,7 @@ public class StringParser
95 98
      * @return String
96 99
      */
97 100
     public static Integer getLength(String s) {
98
-        return null;
101
+        return s.length();
99 102
     }
100 103
 
101 104
     /**
@@ -109,7 +112,7 @@ public class StringParser
109 112
      * @return String
110 113
      */
111 114
     public static Boolean isEqual(String s1, String s2) {
112
-        return null;
115
+        return s1.equals(s2);
113 116
     }
114 117
 
115 118
     /**
@@ -123,6 +126,7 @@ public class StringParser
123 126
      * @return String
124 127
      */
125 128
     public static Boolean isEqualIgnoreCase(String s1, String s2) {
126
-        return null;
129
+        boolean fai = s1.equalsIgnoreCase(s2);
130
+        return fai;
127 131
     }
128 132
 }

+ 2
- 2
package.bluej View File

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