Xzavia Cuello пре 8 година
родитељ
комит
7f7d3468ff
6 измењених фајлова са 28 додато и 17 уклоњено
  1. BIN
      StringParser.class
  2. 1
    1
      StringParser.ctxt
  3. 22
    11
      StringParser.java
  4. BIN
      StringParserTest.class
  5. 1
    1
      StringParserTest.java
  6. 4
    4
      package.bluej

BIN
StringParser.class Прегледај датотеку


+ 1
- 1
StringParser.ctxt Прегледај датотеку

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=\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
 comment7.params=s
25
 comment7.params=s
26
 comment7.target=java.lang.String\ snakeCaseString(java.lang.String)
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
 comment8.params=s
28
 comment8.params=s
29
 comment8.target=java.lang.Integer\ getLength(java.lang.String)
29
 comment8.target=java.lang.Integer\ getLength(java.lang.String)
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
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
      */
15
      */
16
     public static String upperCaseString(String s)
16
     public static String upperCaseString(String s)
17
     {
17
     {
18
-        return null;
18
+
19
+        return s.toUpperCase();
19
     }
20
     }
20
 
21
 
21
     /**
22
     /**
26
      * @return String
27
      * @return String
27
      */
28
      */
28
     public static String lowerCaseString(String s) {
29
     public static String lowerCaseString(String s) {
29
-        return null;
30
+
31
+        return s.toLowerCase();
30
     }
32
     }
31
 
33
 
32
     /**
34
     /**
37
      * @return String
39
      * @return String
38
      */
40
      */
39
     public static Character getFirstCharacter(String s) {
41
     public static Character getFirstCharacter(String s) {
40
-        return null;
42
+
43
+        return s.charAt(0);
41
     }
44
     }
42
 
45
 
43
     /**
46
     /**
49
      * @return String
52
      * @return String
50
      */
53
      */
51
     public static Character getNthCharacter(String s, Integer n) {
54
     public static Character getNthCharacter(String s, Integer n) {
52
-        return null;
55
+        return s.charAt(n);
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
+        return s = Character.toUpperCase(s.charAt(0)) + s.substring(1); 
64
     }
67
     }
65
 
68
 
66
     /**
69
     /**
72
      * @return String
75
      * @return String
73
      */
76
      */
74
     public static String camelCaseString(String s) {
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
      * Takes a String and returns that string with each character lowercased
90
      * Takes a String and returns that string with each character lowercased
80
      * and then joined with an underscore
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
      * @param s
94
      * @param s
84
      * @return String
95
      * @return String
85
      */
96
      */
86
     public static String snakeCaseString(String s) {
97
     public static String snakeCaseString(String s) {
87
-        return null;
98
+        return s.replace(" ","_").toLowerCase();
88
     }
99
     }
89
 
100
 
90
     /**
101
     /**
95
      * @return String
106
      * @return String
96
      */
107
      */
97
     public static Integer getLength(String s) {
108
     public static Integer getLength(String s) {
98
-        return null;
109
+        return s.length();
99
     }
110
     }
100
 
111
 
101
     /**
112
     /**
109
      * @return String
120
      * @return String
110
      */
121
      */
111
     public static Boolean isEqual(String s1, String s2) {
122
     public static Boolean isEqual(String s1, String s2) {
112
-        return null;
123
+        return  s1.equals(s2);
113
     }
124
     }
114
 
125
 
115
     /**
126
     /**
123
      * @return String
134
      * @return String
124
      */
135
      */
125
     public static Boolean isEqualIgnoreCase(String s1, String s2) {
136
     public static Boolean isEqualIgnoreCase(String s1, String s2) {
126
-        return null;
137
+        return s1.equalsIgnoreCase(s2);
127
     }
138
     }
128
 }
139
 }

BIN
StringParserTest.class Прегледај датотеку


+ 1
- 1
StringParserTest.java Прегледај датотеку

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

+ 4
- 4
package.bluej Прегледај датотеку

2
 dependency1.from=StringParserTest
2
 dependency1.from=StringParserTest
3
 dependency1.to=StringParser
3
 dependency1.to=StringParser
4
 dependency1.type=UsesDependency
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
 objectbench.height=164
9
 objectbench.height=164
10
 objectbench.width=776
10
 objectbench.width=776
11
 package.divider.horizontal=0.6
11
 package.divider.horizontal=0.6