Nira Parikh пре 8 година
родитељ
комит
2cbe9df9ae
4 измењених фајлова са 67 додато и 24 уклоњено
  1. BIN
      StringParser.class
  2. 1
    1
      StringParser.ctxt
  3. 59
    16
      StringParser.java
  4. 7
    7
      package.bluej

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


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

@@ -18,7 +18,7 @@ comment4.target=java.lang.Character\ getNthCharacter(java.lang.String,\ java.lan
18 18
 comment4.text=\n\ Takes\ a\ String\ and\ returns\ the\ character\ at\ index\ n\ of\ that\ string.\n\ E.G.\ cat,\ 2\ would\ return\ t.\ Embark,\ 4\ would\ return\ r.\n\n\ @param\ s\n\ @param\ n\n\ @return\ String\n
19 19
 comment5.params=s
20 20
 comment5.target=java.lang.String\ upperCaseFirstCharacter(java.lang.String)
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
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\n
22 22
 comment6.params=s
23 23
 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

+ 59
- 16
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
+        String abc = s.toUpperCase();
19
+        return abc;
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
+        String abc = s.toLowerCase();
31
+        return abc;
30 32
     }
31 33
 
32 34
     /**
@@ -37,10 +39,11 @@ public class StringParser
37 39
      * @return String
38 40
      */
39 41
     public static Character getFirstCharacter(String s) {
40
-        return null;
42
+        char first= s.charAt(0);
43
+        return first;
41 44
     }
42 45
 
43
-    /**
46
+    /*
44 47
      * Takes a String and returns the character at index n of that string.
45 48
      * E.G. cat, 2 would return t. Embark, 4 would return r.
46 49
      *
@@ -48,22 +51,28 @@ public class StringParser
48 51
      * @param n
49 52
      * @return String
50 53
      */
51
-    public static Character getNthCharacter(String s, Integer n) {
52
-        return null;
53
-    }
54 54
 
55
-    /**
55
+    public static Character getNthCharacter(String s, Integer n) {   
56
+        char fir = s.charAt(n);
57
+
58
+        return fir;
59
+    }    
60
+
61
+    /*
56 62
      * Takes a String and returns that string with the first character uppercased.
57 63
      * E.G. cat would return Cat. cofFee would return CofFee.
58 64
      *
59 65
      * @param s
60 66
      * @return String
67
+     *
61 68
      */
62 69
     public static String upperCaseFirstCharacter(String s) {
63
-        return null;
70
+        String capital = s.substring(0, 1).toUpperCase() + s.substring(1);
71
+        return capital;
72
+
64 73
     }
65 74
 
66
-    /**
75
+    /*
67 76
      * Takes a String and returns that string with the first character of each word in it uppercased
68 77
      * and then joined.
69 78
      * E.G. dog whistle would return DogWhistle. adjuNCT pRoFessOR would return AdjuctProfessor.
@@ -72,10 +81,21 @@ public class StringParser
72 81
      * @return String
73 82
      */
74 83
     public static String camelCaseString(String s) {
75
-        return null;
84
+        String sum=s.toLowerCase();
85
+        
86
+        String first=sum.split(" ")[0];
87
+        String sec=sum.split(" ")[1];
88
+        
89
+        String firstLet = first.substring(0,1).toUpperCase()+first.substring(1).toLowerCase();
90
+        String othLetters = sec.substring(0,1).toUpperCase()+sec.substring(1).toLowerCase();
91
+        String total=firstLet+othLetters;
92
+        return total ;
76 93
     }
77 94
 
78
-    /**
95
+       
96
+        
97
+    
98
+    /*
79 99
      * Takes a String and returns that string with each character lowercased
80 100
      * and then joined with an underscore
81 101
      * E.G. dog whistle would return dog_whistle. adjuNCT pRoFessOR would return adjuct_professor.
@@ -84,7 +104,19 @@ public class StringParser
84 104
      * @return String
85 105
      */
86 106
     public static String snakeCaseString(String s) {
87
-        return null;
107
+
108
+        int snakeCase = s.length();
109
+        String Sti = "";
110
+
111
+        for (int n = 0; n < snakeCase; n++){
112
+            if (s.charAt (n) == ' '){
113
+                Sti = Sti + '_';
114
+            }
115
+            else 
116
+                Sti = Sti + Character.toLowerCase (s.charAt(n));
117
+        }
118
+
119
+        return Sti;
88 120
     }
89 121
 
90 122
     /**
@@ -94,8 +126,10 @@ public class StringParser
94 126
      * @param s
95 127
      * @return String
96 128
      */
129
+
97 130
     public static Integer getLength(String s) {
98
-        return null;
131
+        return s.length();
132
+
99 133
     }
100 134
 
101 135
     /**
@@ -109,7 +143,11 @@ public class StringParser
109 143
      * @return String
110 144
      */
111 145
     public static Boolean isEqual(String s1, String s2) {
112
-        return null;
146
+        if(s1.equals(s2)) {
147
+            return true;
148
+        } else {
149
+            return false;
150
+        }
113 151
     }
114 152
 
115 153
     /**
@@ -123,6 +161,11 @@ public class StringParser
123 161
      * @return String
124 162
      */
125 163
     public static Boolean isEqualIgnoreCase(String s1, String s2) {
126
-        return null;
164
+        if (s1.equalsIgnoreCase(s2)){
165
+            return true;
166
+        } else {
167
+            return false;
168
+        }
169
+
127 170
     }
128 171
 }

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

@@ -2,18 +2,18 @@
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=709
6
+editor.fx.0.width=869
7
+editor.fx.0.x=400
8
+editor.fx.0.y=23
9 9
 objectbench.height=164
10
-objectbench.width=776
10
+objectbench.width=461
11 11
 package.divider.horizontal=0.6
12 12
 package.divider.vertical=0.6845018450184502
13 13
 package.editor.height=364
14 14
 package.editor.width=674
15
-package.editor.x=0
16
-package.editor.y=23
15
+package.editor.x=241
16
+package.editor.y=142
17 17
 package.frame.height=600
18 18
 package.frame.width=800
19 19
 package.numDependencies=1