#41 JSC

Open
jasamuels wants to merge 1 commits from jasamuels/JavaStringCheese:master into master
2 changed files with 25 additions and 10 deletions
  1. BIN
      StringParser.class
  2. 25
    10
      StringParser.java

BIN
StringParser.class View File


+ 25
- 10
StringParser.java View File

15
      */
15
      */
16
     public static String upperCaseString(String s)
16
     public static String upperCaseString(String s)
17
     {
17
     {
18
-        return null;
18
+        return s.toUpperCase();
19
     }
19
     }
20
 
20
 
21
     /**
21
     /**
26
      * @return String
26
      * @return String
27
      */
27
      */
28
     public static String lowerCaseString(String s) {
28
     public static String lowerCaseString(String s) {
29
-        return null;
29
+        return s.toLowerCase();
30
     }
30
     }
31
 
31
 
32
     /**
32
     /**
37
      * @return String
37
      * @return String
38
      */
38
      */
39
     public static Character getFirstCharacter(String s) {
39
     public static Character getFirstCharacter(String s) {
40
-        return null;
40
+        String convert = s.substring(0,1);
41
+        char solution = convert.charAt(0);
42
+        return solution;
41
     }
43
     }
42
 
44
 
43
     /**
45
     /**
49
      * @return String
51
      * @return String
50
      */
52
      */
51
     public static Character getNthCharacter(String s, Integer n) {
53
     public static Character getNthCharacter(String s, Integer n) {
52
-        return null;
54
+        int firstnum = n + 1;
55
+        String thechar = s.substring(n,firstnum);
56
+        char itsthechar = thechar.charAt(0);
57
+        return itsthechar;
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
+        int length = s.length();
69
+        String upperchar = s.substring(0,1).toUpperCase();
70
+        return upperchar + s.substring(1,length);
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[] splitem = s.split("\\s+");
83
+    String upperchar1 = splitem[0].substring(0,1).toUpperCase();
84
+    String upperchar2 = splitem[1].substring(0,1).toUpperCase();
85
+    String lowerchar1 = splitem[0].substring(1,splitem[0].length()).toLowerCase();
86
+    String lowerchar2 = splitem[1].substring(1,splitem[1].length()).toLowerCase();
87
+    return upperchar1 + lowerchar1 + upperchar2 + lowerchar2;
76
     }
88
     }
77
 
89
 
78
     /**
90
     /**
84
      * @return String
96
      * @return String
85
      */
97
      */
86
     public static String snakeCaseString(String s) {
98
     public static String snakeCaseString(String s) {
87
-        return null;
99
+    String[] splitem = s.split("\\s+");
100
+    String first = splitem[0].toLowerCase();
101
+    String second = splitem[1].toLowerCase();
102
+    return first + "_" + second;
88
     }
103
     }
89
 
104
 
90
     /**
105
     /**
95
      * @return String
110
      * @return String
96
      */
111
      */
97
     public static Integer getLength(String s) {
112
     public static Integer getLength(String s) {
98
-        return null;
113
+        return s.length();
99
     }
114
     }
100
 
115
 
101
     /**
116
     /**
109
      * @return String
124
      * @return String
110
      */
125
      */
111
     public static Boolean isEqual(String s1, String s2) {
126
     public static Boolean isEqual(String s1, String s2) {
112
-        return null;
127
+        if (s1 == s2) {return true;} else {return false;}
113
     }
128
     }
114
 
129
 
115
     /**
130
     /**
123
      * @return String
138
      * @return String
124
      */
139
      */
125
     public static Boolean isEqualIgnoreCase(String s1, String s2) {
140
     public static Boolean isEqualIgnoreCase(String s1, String s2) {
126
-        return null;
141
+        return s1.equals(s2);
127
     }
142
     }
128
 }
143
 }