浏览代码

Committed changes

Elliott Stansbury 6 年前
父节点
当前提交
9845865a5e
共有 3 个文件被更改,包括 88 次插入11 次删除
  1. 二进制
      StringParser.class
  2. 51
    10
      StringParser.java
  3. 37
    1
      package.bluej

二进制
StringParser.class 查看文件


+ 51
- 10
StringParser.java 查看文件

@@ -15,7 +15,8 @@ public class StringParser
15 15
      */
16 16
     public static String upperCaseString(String s)
17 17
     {
18
-        return null;
18
+
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,9 @@ public class StringParser
37 38
      * @return String
38 39
      */
39 40
     public static Character getFirstCharacter(String s) {
40
-        return null;
41
+        char firstLetter = s.charAt(0);
42
+
43
+        return firstLetter;
41 44
     }
42 45
 
43 46
     /**
@@ -49,7 +52,9 @@ public class StringParser
49 52
      * @return String
50 53
      */
51 54
     public static Character getNthCharacter(String s, Integer n) {
52
-        return null;
55
+        char nLetter = s.charAt(n);
56
+
57
+        return nLetter;
53 58
     }
54 59
 
55 60
     /**
@@ -60,7 +65,9 @@ public class StringParser
60 65
      * @return String
61 66
      */
62 67
     public static String upperCaseFirstCharacter(String s) {
63
-        return null;
68
+        String firstLetterUpper = s.substring(0,1).toUpperCase() + s.substring(1);
69
+
70
+        return firstLetterUpper;
64 71
     }
65 72
 
66 73
     /**
@@ -72,7 +79,23 @@ public class StringParser
72 79
      * @return String
73 80
      */
74 81
     public static String camelCaseString(String s) {
75
-        return null;
82
+        String st = s.toLowerCase();
83
+        String[] arr = st.split(" ");
84
+        StringBuffer sb = new StringBuffer();
85
+
86
+        for (int i = 0; i < arr.length; i++) {
87
+            sb.append(Character.toUpperCase(arr[i].charAt(0)))
88
+            .append(arr[i].substring(1));
89
+        }          
90
+        
91
+       
92
+        
93
+        String a = sb.toString();
94
+        
95
+        
96
+        
97
+        return a;
98
+
76 99
     }
77 100
 
78 101
     /**
@@ -84,7 +107,11 @@ public class StringParser
84 107
      * @return String
85 108
      */
86 109
     public static String snakeCaseString(String s) {
87
-        return null;
110
+        String lower = s.toLowerCase();
111
+        String a = lower.replaceAll("\\s","_");
112
+        
113
+        
114
+        return a;
88 115
     }
89 116
 
90 117
     /**
@@ -95,7 +122,7 @@ public class StringParser
95 122
      * @return String
96 123
      */
97 124
     public static Integer getLength(String s) {
98
-        return null;
125
+        return s.length();
99 126
     }
100 127
 
101 128
     /**
@@ -109,7 +136,11 @@ public class StringParser
109 136
      * @return String
110 137
      */
111 138
     public static Boolean isEqual(String s1, String s2) {
112
-        return null;
139
+        if(s1.equals(s2)){
140
+            return true;
141
+        }else{
142
+        }
143
+        return false;
113 144
     }
114 145
 
115 146
     /**
@@ -123,6 +154,16 @@ public class StringParser
123 154
      * @return String
124 155
      */
125 156
     public static Boolean isEqualIgnoreCase(String s1, String s2) {
126
-        return null;
157
+        
158
+        
159
+        
160
+       
161
+        
162
+        if(s1.equalsIgnoreCase(s2)){
163
+            return true;
164
+        }else {
165
+        }
166
+        return false;
167
+        
127 168
     }
128 169
 }

+ 37
- 1
package.bluej 查看文件

@@ -1,3 +1,39 @@
1 1
 #BlueJ package file
2
-#Wed Oct 17 09:06:47 EDT 2018
2
+editor.fx.0.height=709
3
+editor.fx.0.width=800
4
+editor.fx.0.x=240
5
+editor.fx.0.y=23
6
+objectbench.height=101
7
+objectbench.width=776
8
+package.divider.horizontal=0.6
9
+package.divider.vertical=0.8007380073800738
10
+package.editor.height=427
11
+package.editor.width=674
12
+package.editor.x=227
13
+package.editor.y=43
14
+package.frame.height=600
15
+package.frame.width=800
16
+package.numDependencies=0
17
+package.numTargets=2
18
+package.showExtends=true
19
+package.showUses=true
3 20
 project.charset=UTF-8
21
+readme.height=58
22
+readme.name=@README
23
+readme.width=47
24
+readme.x=10
25
+readme.y=10
26
+target1.height=50
27
+target1.name=StringParser
28
+target1.showInterface=false
29
+target1.type=ClassTarget
30
+target1.width=100
31
+target1.x=140
32
+target1.y=10
33
+target2.height=50
34
+target2.name=StringParserTest
35
+target2.showInterface=false
36
+target2.type=UnitTestTargetJunit4
37
+target2.width=130
38
+target2.x=70
39
+target2.y=70