Browse Source

strig cheese

Nuridalia Hermandez 6 years ago
parent
commit
8f184ec7af
6 changed files with 71 additions and 14 deletions
  1. BIN
      StringParser.class
  2. 1
    1
      StringParser.ctxt
  3. 33
    11
      StringParser.java
  4. BIN
      StringParserTest.class
  5. 0
    1
      StringParserTest.java
  6. 37
    1
      package.bluej

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=\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

+ 33
- 11
StringParser.java View File

@@ -15,7 +15,8 @@ public class StringParser
15 15
      */
16 16
     public static String upperCaseString(String s)
17 17
     {
18
-        return null;
18
+        String str = s.toUpperCase();
19
+        return str;
19 20
     }
20 21
 
21 22
     /**
@@ -26,7 +27,9 @@ public class StringParser
26 27
      * @return String
27 28
      */
28 29
     public static String lowerCaseString(String s) {
29
-        return null;
30
+        String str = s.toLowerCase();
31
+
32
+        return str;
30 33
     }
31 34
 
32 35
     /**
@@ -37,7 +40,10 @@ public class StringParser
37 40
      * @return String
38 41
      */
39 42
     public static Character getFirstCharacter(String s) {
40
-        return null;
43
+
44
+        char str = s.charAt(0);
45
+
46
+        return str ;
41 47
     }
42 48
 
43 49
     /**
@@ -49,7 +55,8 @@ public class StringParser
49 55
      * @return String
50 56
      */
51 57
     public static Character getNthCharacter(String s, Integer n) {
52
-        return null;
58
+        char str =s.charAt(n);
59
+        return str;
53 60
     }
54 61
 
55 62
     /**
@@ -60,19 +67,29 @@ public class StringParser
60 67
      * @return String
61 68
      */
62 69
     public static String upperCaseFirstCharacter(String s) {
63
-        return null;
70
+        String str= s.substring(0, 1).toUpperCase() + s.substring(1);
71
+        return str;
64 72
     }
65 73
 
66 74
     /**
67 75
      * Takes a String and returns that string with the first character of each word in it uppercased
68 76
      * and then joined.
69 77
      * E.G. dog whistle would return DogWhistle. adjuNCT pRoFessOR would return AdjuctProfessor.
70
-     *
78
+     *;
71 79
      * @param s
72 80
      * @return String
73 81
      */
74 82
     public static String camelCaseString(String s) {
75
-        return null;
83
+        String str = s.toLowerCase();
84
+
85
+        String  x = str. split(" ")[0];
86
+        String  y= str.split (" ")[1];
87
+
88
+        String upperCase = x.substring(0, 1).toUpperCase() + x.substring(1).toLowerCase();
89
+        String upperCase1 = y.substring(0, 1).toUpperCase()+y.substring(1).toLowerCase();
90
+        String last = upperCase + upperCase1;
91
+
92
+        return last.trim();
76 93
     }
77 94
 
78 95
     /**
@@ -84,7 +101,10 @@ public class StringParser
84 101
      * @return String
85 102
      */
86 103
     public static String snakeCaseString(String s) {
87
-        return null;
104
+        String str = s.toLowerCase();
105
+        String first= str.replace(" ", "_");
106
+
107
+        return first;
88 108
     }
89 109
 
90 110
     /**
@@ -95,7 +115,7 @@ public class StringParser
95 115
      * @return String
96 116
      */
97 117
     public static Integer getLength(String s) {
98
-        return null;
118
+        return s.length();
99 119
     }
100 120
 
101 121
     /**
@@ -109,7 +129,8 @@ public class StringParser
109 129
      * @return String
110 130
      */
111 131
     public static Boolean isEqual(String s1, String s2) {
112
-        return null;
132
+
133
+        return s1.equals(s2);
113 134
     }
114 135
 
115 136
     /**
@@ -123,6 +144,7 @@ public class StringParser
123 144
      * @return String
124 145
      */
125 146
     public static Boolean isEqualIgnoreCase(String s1, String s2) {
126
-        return null;
147
+        return s1.equalsIgnoreCase(s2);
148
+
127 149
     }
128 150
 }

BIN
StringParserTest.class View File


+ 0
- 1
StringParserTest.java View File

@@ -148,7 +148,6 @@ public class StringParserTest {
148 148
         String compareString3 = "A different string!";
149 149
         Boolean expected3 = false;
150 150
 
151
-
152 151
         //When
153 152
         Boolean actual1 = StringParser.isEqualIgnoreCase(string1, compareString1);
154 153
         Boolean actual2 = StringParser.isEqualIgnoreCase(string2, compareString2);

+ 37
- 1
package.bluej View File

@@ -1,3 +1,39 @@
1 1
 #BlueJ package file
2
-#Wed Oct 17 09:06:47 EDT 2018
2
+editor.fx.0.height=722
3
+editor.fx.0.width=800
4
+editor.fx.0.x=767
5
+editor.fx.0.y=23
6
+objectbench.height=101
7
+objectbench.width=776
8
+package.divider.horizontal=0.6
9
+package.divider.vertical=0.8007380073800738
10
+package.editor.height=427
11
+package.editor.width=674
12
+package.editor.x=203
13
+package.editor.y=43
14
+package.frame.height=600
15
+package.frame.width=800
16
+package.numDependencies=0
17
+package.numTargets=2
18
+package.showExtends=true
19
+package.showUses=true
3 20
 project.charset=UTF-8
21
+readme.height=58
22
+readme.name=@README
23
+readme.width=47
24
+readme.x=10
25
+readme.y=10
26
+target1.height=50
27
+target1.name=StringParser
28
+target1.showInterface=false
29
+target1.type=ClassTarget
30
+target1.width=100
31
+target1.x=140
32
+target1.y=10
33
+target2.height=50
34
+target2.name=StringParserTest
35
+target2.showInterface=false
36
+target2.type=UnitTestTargetJunit4
37
+target2.width=130
38
+target2.x=70
39
+target2.y=70