#40 Joson JavaStringCheese

Open
jaejoson wants to merge 1 commits from jaejoson/JavaStringCheese:master into master
3 changed files with 44 additions and 12 deletions
  1. BIN
      StringParser.class
  2. 1
    1
      StringParser.ctxt
  3. 43
    11
      StringParser.java

BIN
StringParser.class View File


+ 1
- 1
StringParser.ctxt View File

@@ -21,7 +21,7 @@ comment5.target=java.lang.String\ upperCaseFirstCharacter(java.lang.String)
21 21
 comment5.text=\n\ Takes\ a\ String\ and\ returns\ that\ string\ with\ the\ first\ character\ uppercased.\n\ E.G.\ cat\ would\ return\ Cat.\ cofFee\ would\ return\ CofFee.\n\n\ @param\ s\n\ @return\ String\n
22 22
 comment6.params=s
23 23
 comment6.target=java.lang.String\ camelCaseString(java.lang.String)
24
-comment6.text=\n\ Takes\ a\ String\ and\ returns\ that\ string\ with\ the\ first\ character\ of\ each\ word\ in\ it\ uppercased\n\ and\ then\ joined.\n\ E.G.\ dog\ whistle\ would\ return\ DogWhistle.\ adjuNCT\ pRoFessOR\ would\ return\ AdjuctProfessor.\n\n\ @param\ s\n\ @return\ String\n
24
+comment6.text=\ NEED\ TO\ FINISH\n\ Takes\ a\ String\ and\ returns\ that\ string\ with\ the\ first\ character\ of\ each\ word\ in\ it\ uppercased\n\ and\ then\ joined.\n\ E.G.\ dog\ whistle\ would\ return\ DogWhistle.\ adjuNCT\ pRoFessOR\ would\ return\ AdjuctProfessor.\n\n\ @param\ s\n\ @return\ String\n
25 25
 comment7.params=s
26 26
 comment7.target=java.lang.String\ snakeCaseString(java.lang.String)
27 27
 comment7.text=\n\ Takes\ a\ String\ and\ returns\ that\ string\ with\ each\ character\ lowercased\n\ and\ then\ joined\ with\ an\ underscore\n\ E.G.\ dog\ whistle\ would\ return\ dog_whistle.\ adjuNCT\ pRoFessOR\ would\ return\ adjuct_professor.\n\n\ @param\ s\n\ @return\ String\n

+ 43
- 11
StringParser.java View File

@@ -15,7 +15,7 @@ public class StringParser
15 15
      */
16 16
     public static String upperCaseString(String s)
17 17
     {
18
-        return null;
18
+        return s.toUpperCase(); 
19 19
     }
20 20
 
21 21
     /**
@@ -26,7 +26,7 @@ public class StringParser
26 26
      * @return String
27 27
      */
28 28
     public static String lowerCaseString(String s) {
29
-        return null;
29
+        return s.toLowerCase();
30 30
     }
31 31
 
32 32
     /**
@@ -37,7 +37,7 @@ public class StringParser
37 37
      * @return String
38 38
      */
39 39
     public static Character getFirstCharacter(String s) {
40
-        return null;
40
+         return s.charAt(0); 
41 41
     }
42 42
 
43 43
     /**
@@ -49,7 +49,7 @@ public class StringParser
49 49
      * @return String
50 50
      */
51 51
     public static Character getNthCharacter(String s, Integer n) {
52
-        return null;
52
+        return s.charAt(n);
53 53
     }
54 54
 
55 55
     /**
@@ -60,10 +60,13 @@ public class StringParser
60 60
      * @return String
61 61
      */
62 62
     public static String upperCaseFirstCharacter(String s) {
63
-        return null;
63
+        String str = s; 
64
+        String cap = str.substring(0,1).toUpperCase() + str.substring(1);
65
+        return cap;
66
+    
64 67
     }
65 68
 
66
-    /**
69
+    /** NEED TO FINISH
67 70
      * Takes a String and returns that string with the first character of each word in it uppercased
68 71
      * and then joined.
69 72
      * E.G. dog whistle would return DogWhistle. adjuNCT pRoFessOR would return AdjuctProfessor.
@@ -72,7 +75,19 @@ public class StringParser
72 75
      * @return String
73 76
      */
74 77
     public static String camelCaseString(String s) {
75
-        return null;
78
+        String lower = s.toLowerCase();
79
+        String first = " ";
80
+        for (int i = 0; i < lower.length(); i++) {
81
+            if (Character.isWhitespace(lower.charAt(i))) {
82
+                first = lower.substring(0,i);
83
+                break;
84
+            }
85
+        }
86
+        first = first.substring(0,1).toUpperCase() + first.substring(1);
87
+        String second = lower.substring(first.length()+1);
88
+        second = second.substring(0,1).toUpperCase() + second.substring(1);
89
+        String cC = first + second; 
90
+        return cC; 
76 91
     }
77 92
 
78 93
     /**
@@ -84,7 +99,13 @@ public class StringParser
84 99
      * @return String
85 100
      */
86 101
     public static String snakeCaseString(String s) {
87
-        return null;
102
+      
103
+        String itemname = s;
104
+        itemname = itemname.replaceAll(" ","_").toLowerCase();
105
+        String finale = itemname; 
106
+        System.out.print(finale);
107
+        return finale; 
108
+        
88 109
     }
89 110
 
90 111
     /**
@@ -95,7 +116,7 @@ public class StringParser
95 116
      * @return String
96 117
      */
97 118
     public static Integer getLength(String s) {
98
-        return null;
119
+        return s.length();
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 == s2) {
134
+            return true;
135
+        } else {
136
+            return false;
137
+        }
113 138
     }
114 139
 
115 140
     /**
@@ -123,6 +148,13 @@ public class StringParser
123 148
      * @return String
124 149
      */
125 150
     public static Boolean isEqualIgnoreCase(String s1, String s2) {
126
-        return null;
151
+        
152
+        if (s1.equalsIgnoreCase(s2)) {
153
+            return true;
154
+        } else {
155
+            return false;
156
+        }
157
+           
127 158
     }
159
+   
128 160
 }