Xzavia Cuello 6 лет назад
Родитель
Сommit
7f7d3468ff
6 измененных файлов: 28 добавлений и 17 удалений
  1. Двоичные данные
      StringParser.class
  2. 1
    1
      StringParser.ctxt
  3. 22
    11
      StringParser.java
  4. Двоичные данные
      StringParserTest.class
  5. 1
    1
      StringParserTest.java
  6. 4
    4
      package.bluej

Двоичные данные
StringParser.class Просмотреть файл


+ 1
- 1
StringParser.ctxt Просмотреть файл

@@ -24,7 +24,7 @@ comment6.target=java.lang.String\ camelCaseString(java.lang.String)
24 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
25 25
 comment7.params=s
26 26
 comment7.target=java.lang.String\ snakeCaseString(java.lang.String)
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
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
28 28
 comment8.params=s
29 29
 comment8.target=java.lang.Integer\ getLength(java.lang.String)
30 30
 comment8.text=\n\ Takes\ a\ String\ and\ returns\ the\ length\ of\ that\ string\n\ E.G.\ cat\ would\ return\ 3.\ extra\ would\ return\ 5.\n\n\ @param\ s\n\ @return\ String\n

+ 22
- 11
StringParser.java Просмотреть файл

@@ -15,7 +15,8 @@ public class StringParser
15 15
      */
16 16
     public static String upperCaseString(String s)
17 17
     {
18
-        return null;
18
+
19
+        return s.toUpperCase();
19 20
     }
20 21
 
21 22
     /**
@@ -26,7 +27,8 @@ public class StringParser
26 27
      * @return String
27 28
      */
28 29
     public static String lowerCaseString(String s) {
29
-        return null;
30
+
31
+        return s.toLowerCase();
30 32
     }
31 33
 
32 34
     /**
@@ -37,7 +39,8 @@ public class StringParser
37 39
      * @return String
38 40
      */
39 41
     public static Character getFirstCharacter(String s) {
40
-        return null;
42
+
43
+        return s.charAt(0);
41 44
     }
42 45
 
43 46
     /**
@@ -49,7 +52,7 @@ public class StringParser
49 52
      * @return String
50 53
      */
51 54
     public static Character getNthCharacter(String s, Integer n) {
52
-        return null;
55
+        return s.charAt(n);
53 56
     }
54 57
 
55 58
     /**
@@ -60,7 +63,7 @@ public class StringParser
60 63
      * @return String
61 64
      */
62 65
     public static String upperCaseFirstCharacter(String s) {
63
-        return null;
66
+        return s = Character.toUpperCase(s.charAt(0)) + s.substring(1); 
64 67
     }
65 68
 
66 69
     /**
@@ -72,19 +75,27 @@ public class StringParser
72 75
      * @return String
73 76
      */
74 77
     public static String camelCaseString(String s) {
75
-        return null;
78
+
79
+        String camalCase2 = "";
80
+        String camalCase3 = s.toLowerCase();
81
+        String[] camalCase = camalCase3.split(" ");
82
+        for(int i = 0; i < camalCase.length; i++){
83
+            camalCase2 += camalCase[i].substring(0,1).toUpperCase();
84
+            camalCase2 += camalCase[i].substring(1);
85
+        }
86
+        return camalCase2;
76 87
     }
77 88
 
78 89
     /**
79 90
      * Takes a String and returns that string with each character lowercased
80 91
      * and then joined with an underscore
81
-     * E.G. dog whistle would return dog_whistle. adjuNCT pRoFessOR would return adjuct_professor.
92
+     * E.G. "dog whistle" would return dog_whistle. adjuNCT pRoFessOR would return adjuct_professor.
82 93
      *
83 94
      * @param s
84 95
      * @return String
85 96
      */
86 97
     public static String snakeCaseString(String s) {
87
-        return null;
98
+        return s.replace(" ","_").toLowerCase();
88 99
     }
89 100
 
90 101
     /**
@@ -95,7 +106,7 @@ public class StringParser
95 106
      * @return String
96 107
      */
97 108
     public static Integer getLength(String s) {
98
-        return null;
109
+        return s.length();
99 110
     }
100 111
 
101 112
     /**
@@ -109,7 +120,7 @@ public class StringParser
109 120
      * @return String
110 121
      */
111 122
     public static Boolean isEqual(String s1, String s2) {
112
-        return null;
123
+        return  s1.equals(s2);
113 124
     }
114 125
 
115 126
     /**
@@ -123,6 +134,6 @@ public class StringParser
123 134
      * @return String
124 135
      */
125 136
     public static Boolean isEqualIgnoreCase(String s1, String s2) {
126
-        return null;
137
+        return s1.equalsIgnoreCase(s2);
127 138
     }
128 139
 }

Двоичные данные
StringParserTest.class Просмотреть файл


+ 1
- 1
StringParserTest.java Просмотреть файл

@@ -72,7 +72,7 @@ public class StringParserTest {
72 72
     @Test
73 73
     public void camelCaseString() {
74 74
         //Given
75
-        String string1 = "tEsT sTrInG";
75
+        String string1 = "test sTrInG";
76 76
         String expected = "TestString";
77 77
 
78 78
         //When

+ 4
- 4
package.bluej Просмотреть файл

@@ -2,10 +2,10 @@
2 2
 dependency1.from=StringParserTest
3 3
 dependency1.to=StringParser
4 4
 dependency1.type=UsesDependency
5
-editor.fx.0.height=722
6
-editor.fx.0.width=800
7
-editor.fx.0.x=455
8
-editor.fx.0.y=51
5
+editor.fx.0.height=714
6
+editor.fx.0.width=902
7
+editor.fx.0.x=350
8
+editor.fx.0.y=23
9 9
 objectbench.height=164
10 10
 objectbench.width=776
11 11
 package.divider.horizontal=0.6