Whitney Martinez 8 年之前
父節點
當前提交
d558652e23
共有 3 個檔案被更改,包括 43 行新增12 行删除
  1. 二進制
      StringParser.class
  2. 1
    1
      StringParser.ctxt
  3. 42
    11
      StringParser.java

二進制
StringParser.class 查看文件


+ 1
- 1
StringParser.ctxt 查看文件

6
 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
6
 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
7
 comment10.params=s1\ s2
7
 comment10.params=s1\ s2
8
 comment10.target=java.lang.Boolean\ isEqualIgnoreCase(java.lang.String,\ java.lang.String)
8
 comment10.target=java.lang.Boolean\ isEqualIgnoreCase(java.lang.String,\ java.lang.String)
9
-comment10.text=\n\ Takes\ in\ two\ strings\ and\ returns\ true\ if\ they\ are\ equal\n\ E.G.\ example\ and\ shelf\ would\ return\ false.\ \n\ cat\ and\ CaT\ would\ return\ true.\ \n\ Dog\ and\ Dog\ would\ return\ true\n\n\ @param\ s1\n\ @param\ s2\n\ @return\ String\n
9
+comment10.text=\n\ Takes\ in\ two\ strings\ and\ returns\ true\ if\ they\ are\ equal\n\ E.G.\ example\ and\ shelf\ would\ return\ false.\ \n\ cat\ and\ CaT\ would\ return\ true.\ \n\ Dog\ and\ Dog\ would\ return\ true\n\n\ @param\ s1)\n\ @param\ s2\n\ @return\ String\n
10
 comment2.params=s
10
 comment2.params=s
11
 comment2.target=java.lang.String\ lowerCaseString(java.lang.String)
11
 comment2.target=java.lang.String\ lowerCaseString(java.lang.String)
12
 comment2.text=\n\ Takes\ a\ String\ and\ returns\ that\ String\ with\ all\ characters\ lowercased.\n\ E.G.\ MOUSE\ would\ become\ mouse.\ dOnUt\ would\ become\ donut.\n\n\ @param\ s\n\ @return\ String\n
12
 comment2.text=\n\ Takes\ a\ String\ and\ returns\ that\ String\ with\ all\ characters\ lowercased.\n\ E.G.\ MOUSE\ would\ become\ mouse.\ dOnUt\ would\ become\ donut.\n\n\ @param\ s\n\ @return\ String\n

+ 42
- 11
StringParser.java 查看文件

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
+       return s.charAt(0);
41
     }
41
     }
42
 
42
 
43
     /**
43
     /**
49
      * @return String
49
      * @return String
50
      */
50
      */
51
     public static Character getNthCharacter(String s, Integer n) {
51
     public static Character getNthCharacter(String s, Integer n) {
52
-        return null;
52
+        
53
+        char c = s.charAt(n);
54
+        
55
+        return c;
53
     }
56
     }
54
 
57
 
55
     /**
58
     /**
60
      * @return String
63
      * @return String
61
      */
64
      */
62
     public static String upperCaseFirstCharacter(String s) {
65
     public static String upperCaseFirstCharacter(String s) {
63
-        return null;
66
+        // substring has a beginning index and end index
67
+        // if one doesn't put the end index it'll return the rest of the words
68
+        // after the beginning index. Else it'll just return 1 character in thid
69
+        // exercise. 
70
+        
71
+        String c = s.substring(0,1).toUpperCase() + s.substring(1);
72
+        return c;
73
+        
64
     }
74
     }
65
 
75
 
66
     /**
76
     /**
72
      * @return String
82
      * @return String
73
      */
83
      */
74
     public static String camelCaseString(String s) {
84
     public static String camelCaseString(String s) {
75
-        return null;
85
+        String c = s.toLowerCase();
86
+        String x1 = c.split(" ")[0];
87
+        String x2 = c.split(" ")[1];
88
+        String container = x1.substring(0,1).toUpperCase() + x1.substring(1);
89
+        String container1 = x2.substring(0,1).toUpperCase() + x2.substring(1);
90
+        String putittogether = container + container1;
91
+       
92
+        return putittogether.trim();
93
+        
94
+        
95
+        
76
     }
96
     }
77
 
97
 
78
     /**
98
     /**
84
      * @return String
104
      * @return String
85
      */
105
      */
86
     public static String snakeCaseString(String s) {
106
     public static String snakeCaseString(String s) {
87
-        return null;
107
+        String c = s.replace(" ","_");
108
+        
109
+        return c.toLowerCase();
88
     }
110
     }
89
 
111
 
90
     /**
112
     /**
95
      * @return String
117
      * @return String
96
      */
118
      */
97
     public static Integer getLength(String s) {
119
     public static Integer getLength(String s) {
98
-        return null;
120
+        int c = s.length();
121
+        return c;
99
     }
122
     }
100
 
123
 
101
     /**
124
     /**
109
      * @return String
132
      * @return String
110
      */
133
      */
111
     public static Boolean isEqual(String s1, String s2) {
134
     public static Boolean isEqual(String s1, String s2) {
112
-        return null;
135
+        if (s1.equals(s2)){
136
+            return true;
137
+        
138
+        }
139
+        return false;
113
     }
140
     }
114
 
141
 
115
     /**
142
     /**
118
      * cat and CaT would return true. 
145
      * cat and CaT would return true. 
119
      * Dog and Dog would return true
146
      * Dog and Dog would return true
120
      *
147
      *
121
-     * @param s1
148
+     * @param s1)
122
      * @param s2
149
      * @param s2
123
      * @return String
150
      * @return String
124
      */
151
      */
125
     public static Boolean isEqualIgnoreCase(String s1, String s2) {
152
     public static Boolean isEqualIgnoreCase(String s1, String s2) {
126
-        return null;
153
+        if(s1.equalsIgnoreCase(s2)){
154
+            return true;
155
+        
156
+        }
157
+        return false;
127
     }
158
     }
128
 }
159
 }