Przeglądaj źródła

I completed this assignment

De'Jon Johnson 6 lat temu
rodzic
commit
0149c15496
3 zmienionych plików z 36 dodań i 15 usunięć
  1. BIN
      StringParser.class
  2. 32
    11
      StringParser.java
  3. 4
    4
      package.bluej

BIN
StringParser.class Wyświetl plik


+ 32
- 11
StringParser.java Wyświetl plik

@@ -15,7 +15,9 @@ public class StringParser
15 15
      */
16 16
     public static String upperCaseString(String s)
17 17
     {
18
-        return null;
18
+        String newVar = new String(s);
19
+
20
+        return newVar.toUpperCase();
19 21
     }
20 22
 
21 23
     /**
@@ -26,7 +28,8 @@ public class StringParser
26 28
      * @return String
27 29
      */
28 30
     public static String lowerCaseString(String s) {
29
-        return null;
31
+        String newVar = s.toLowerCase();
32
+        return newVar;
30 33
     }
31 34
 
32 35
     /**
@@ -37,7 +40,9 @@ public class StringParser
37 40
      * @return String
38 41
      */
39 42
     public static Character getFirstCharacter(String s) {
40
-        return null;
43
+        char newVar = s.charAt(0);
44
+        return newVar;
45
+
41 46
     }
42 47
 
43 48
     /**
@@ -49,7 +54,9 @@ public class StringParser
49 54
      * @return String
50 55
      */
51 56
     public static Character getNthCharacter(String s, Integer n) {
52
-        return null;
57
+        char newVar = s.charAt(n);
58
+        return newVar;
59
+
53 60
     }
54 61
 
55 62
     /**
@@ -60,7 +67,10 @@ public class StringParser
60 67
      * @return String
61 68
      */
62 69
     public static String upperCaseFirstCharacter(String s) {
63
-        return null;
70
+        String newVar = s.substring(0, 1).toUpperCase() + s.substring(1);
71
+
72
+        return newVar;
73
+
64 74
     }
65 75
 
66 76
     /**
@@ -72,7 +82,14 @@ public class StringParser
72 82
      * @return String
73 83
      */
74 84
     public static String camelCaseString(String s) {
75
-        return null;
85
+        String stringLc = s.toLowerCase();
86
+        String[] stringArray = stringLc.split(" ");
87
+        String finalString = ""; 
88
+        for(int i = 0; i<stringArray.length; i++){
89
+            finalString += stringArray[i].substring(0,1).toUpperCase();
90
+            finalString += stringArray[i].substring(1);
91
+        }
92
+        return finalString;
76 93
     }
77 94
 
78 95
     /**
@@ -84,7 +101,8 @@ public class StringParser
84 101
      * @return String
85 102
      */
86 103
     public static String snakeCaseString(String s) {
87
-        return null;
104
+        String snakeCase = s.replaceAll(" ","_").toLowerCase();
105
+        return snakeCase;
88 106
     }
89 107
 
90 108
     /**
@@ -95,7 +113,9 @@ public class StringParser
95 113
      * @return String
96 114
      */
97 115
     public static Integer getLength(String s) {
98
-        return null;
116
+        int returnedVar = s.length();
117
+        return returnedVar;
118
+     
99 119
     }
100 120
 
101 121
     /**
@@ -109,7 +129,8 @@ public class StringParser
109 129
      * @return String
110 130
      */
111 131
     public static Boolean isEqual(String s1, String s2) {
112
-        return null;
132
+        return s1.equals(s2);
133
+            
113 134
     }
114 135
 
115 136
     /**
@@ -123,6 +144,6 @@ public class StringParser
123 144
      * @return String
124 145
      */
125 146
     public static Boolean isEqualIgnoreCase(String s1, String s2) {
126
-        return null;
147
+        return s1.equalsIgnoreCase(s2);
127 148
     }
128
-}
149
+}

+ 4
- 4
package.bluej Wyświetl plik

@@ -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
6
-editor.fx.0.width=800
7
-editor.fx.0.x=455
8
-editor.fx.0.y=51
5
+editor.fx.0.height=814
6
+editor.fx.0.width=1052
7
+editor.fx.0.x=126
8
+editor.fx.0.y=23
9 9
 objectbench.height=164
10 10
 objectbench.width=776
11 11
 package.divider.horizontal=0.6