Jose Bedolla 6 vuotta sitten
vanhempi
commit
bf917a8ef5
4 muutettua tiedostoa jossa 44 lisäystä ja 16 poistoa
  1. BIN
      StringParser.class
  2. 0
    1
      StringParser.ctxt
  3. 39
    10
      StringParser.java
  4. 5
    5
      package.bluej

BIN
StringParser.class Näytä tiedosto


+ 0
- 1
StringParser.ctxt Näytä tiedosto

@@ -1,6 +1,5 @@
1 1
 #BlueJ class context
2 2
 comment0.target=StringParser
3
-comment0.text=\n\ An\ introduction\ to\ Strings\ and\ String\ methods.\n\n\ @author\ Wilhem\ Alcivar\n
4 3
 comment1.params=s
5 4
 comment1.target=java.lang.String\ upperCaseString(java.lang.String)
6 5
 comment1.text=\n\ Takes\ a\ String\ and\ returns\ that\ String\ with\ all\ characters\ uppercased.\n\ E.G.\ cat\ would\ become\ CAT.\ dOnUt\ would\ become\ DONUT.\n\n\ @param\ s\n\ @return\ String\n

+ 39
- 10
StringParser.java Näytä tiedosto

@@ -4,6 +4,7 @@
4 4
  *
5 5
  * @author Wilhem Alcivar
6 6
  */
7
+import java.util.*;
7 8
 public class StringParser
8 9
 {
9 10
     /**
@@ -15,7 +16,8 @@ public class StringParser
15 16
      */
16 17
     public static String upperCaseString(String s)
17 18
     {
18
-        return null;
19
+        String change = s.toUpperCase();
20
+        return change;
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
+        
32
+        return s.toLowerCase();
30 33
     }
31 34
 
32 35
     /**
@@ -37,7 +40,10 @@ public class StringParser
37 40
      * @return String
38 41
      */
39 42
     public static Character getFirstCharacter(String s) {
40
-        return null;
43
+        
44
+        char first = s.charAt(0);
45
+        return first;
46
+        
41 47
     }
42 48
 
43 49
     /**
@@ -49,7 +55,8 @@ public class StringParser
49 55
      * @return String
50 56
      */
51 57
     public static Character getNthCharacter(String s, Integer n) {
52
-        return null;
58
+        char num = s.charAt(n);
59
+        return num;
53 60
     }
54 61
 
55 62
     /**
@@ -60,7 +67,9 @@ public class StringParser
60 67
      * @return String
61 68
      */
62 69
     public static String upperCaseFirstCharacter(String s) {
63
-        return null;
70
+        String change = s.substring(0,1).toUpperCase();
71
+        String nameCap = change + s.substring(1);
72
+        return nameCap;
64 73
     }
65 74
 
66 75
     /**
@@ -72,7 +81,12 @@ public class StringParser
72 81
      * @return String
73 82
      */
74 83
     public static String camelCaseString(String s) {
75
-        return null;
84
+        s = s.toLowerCase();
85
+        int index = s.indexOf(" ") + 1;
86
+        
87
+        s = s.substring(0,1).toUpperCase() +  s.substring(1,index -1)+ s.substring(index, index +1).toUpperCase() + s.substring(index +1); 
88
+
89
+        return s;
76 90
     }
77 91
 
78 92
     /**
@@ -84,7 +98,12 @@ public class StringParser
84 98
      * @return String
85 99
      */
86 100
     public static String snakeCaseString(String s) {
87
-        return null;
101
+        
102
+        String val = s.toLowerCase();
103
+
104
+        val = val.replaceAll(" ","_");
105
+        
106
+        return val;
88 107
     }
89 108
 
90 109
     /**
@@ -95,7 +114,9 @@ public class StringParser
95 114
      * @return String
96 115
      */
97 116
     public static Integer getLength(String s) {
98
-        return null;
117
+        
118
+        int quantity = s.length();
119
+        return quantity;
99 120
     }
100 121
 
101 122
     /**
@@ -109,7 +130,11 @@ public class StringParser
109 130
      * @return String
110 131
      */
111 132
     public static Boolean isEqual(String s1, String s2) {
112
-        return null;
133
+        if(s1.equals(s2))
134
+        {
135
+            return true;
136
+        }
137
+            return false;
113 138
     }
114 139
 
115 140
     /**
@@ -123,6 +148,10 @@ public class StringParser
123 148
      * @return String
124 149
      */
125 150
     public static Boolean isEqualIgnoreCase(String s1, String s2) {
126
-        return null;
151
+        if(s1.equalsIgnoreCase(s2))
152
+        {
153
+            return true;
154
+        }
155
+        return false;
127 156
     }
128 157
 }

+ 5
- 5
package.bluej Näytä tiedosto

@@ -4,16 +4,16 @@ dependency1.to=StringParser
4 4
 dependency1.type=UsesDependency
5 5
 editor.fx.0.height=722
6 6
 editor.fx.0.width=800
7
-editor.fx.0.x=455
8
-editor.fx.0.y=51
7
+editor.fx.0.x=571
8
+editor.fx.0.y=-1017
9 9
 objectbench.height=164
10 10
 objectbench.width=776
11 11
 package.divider.horizontal=0.6
12 12
 package.divider.vertical=0.6845018450184502
13 13
 package.editor.height=364
14 14
 package.editor.width=674
15
-package.editor.x=0
16
-package.editor.y=23
15
+package.editor.x=-342
16
+package.editor.y=-969
17 17
 package.frame.height=600
18 18
 package.frame.width=800
19 19
 package.numDependencies=1
@@ -32,7 +32,7 @@ target1.showInterface=false
32 32
 target1.type=ClassTarget
33 33
 target1.width=100
34 34
 target1.x=150
35
-target1.y=120
35
+target1.y=110
36 36
 target2.height=50
37 37
 target2.name=StringParserTest
38 38
 target2.showInterface=false