Elliott Stansbury před 6 roky
rodič
revize
9845865a5e
3 změnil soubory, kde provedl 88 přidání a 11 odebrání
  1. binární
      StringParser.class
  2. 51
    10
      StringParser.java
  3. 37
    1
      package.bluej

binární
StringParser.class Zobrazit soubor


+ 51
- 10
StringParser.java Zobrazit soubor

15
      */
15
      */
16
     public static String upperCaseString(String s)
16
     public static String upperCaseString(String s)
17
     {
17
     {
18
-        return null;
18
+
19
+        return s.toUpperCase();
19
     }
20
     }
20
 
21
 
21
     /**
22
     /**
26
      * @return String
27
      * @return String
27
      */
28
      */
28
     public static String lowerCaseString(String s) {
29
     public static String lowerCaseString(String s) {
29
-        return null;
30
+        return s.toLowerCase();
30
     }
31
     }
31
 
32
 
32
     /**
33
     /**
37
      * @return String
38
      * @return String
38
      */
39
      */
39
     public static Character getFirstCharacter(String s) {
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
      * @return String
52
      * @return String
50
      */
53
      */
51
     public static Character getNthCharacter(String s, Integer n) {
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
      * @return String
65
      * @return String
61
      */
66
      */
62
     public static String upperCaseFirstCharacter(String s) {
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
      * @return String
79
      * @return String
73
      */
80
      */
74
     public static String camelCaseString(String s) {
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
      * @return String
107
      * @return String
85
      */
108
      */
86
     public static String snakeCaseString(String s) {
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
      * @return String
122
      * @return String
96
      */
123
      */
97
     public static Integer getLength(String s) {
124
     public static Integer getLength(String s) {
98
-        return null;
125
+        return s.length();
99
     }
126
     }
100
 
127
 
101
     /**
128
     /**
109
      * @return String
136
      * @return String
110
      */
137
      */
111
     public static Boolean isEqual(String s1, String s2) {
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
      * @return String
154
      * @return String
124
      */
155
      */
125
     public static Boolean isEqualIgnoreCase(String s1, String s2) {
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 Zobrazit soubor

1
 #BlueJ package file
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
 project.charset=UTF-8
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