Nhu Nguyen před 6 roky
revize
a44551811c
8 změnil soubory, kde provedl 362 přidání a 0 odebrání
  1. 12
    0
      README.TXT
  2. binární
      StringParser.class
  3. 34
    0
      StringParser.ctxt
  4. 128
    0
      StringParser.java
  5. binární
      StringParserTest.class
  6. 23
    0
      StringParserTest.ctxt
  7. 162
    0
      StringParserTest.java
  8. 3
    0
      package.bluej

+ 12
- 0
README.TXT Zobrazit soubor

@@ -0,0 +1,12 @@
1
+------------------------------------------------------------------------
2
+This is the project README file. Here, you should describe your project.
3
+Tell the reader (someone who does not know anything about this project)
4
+all he/she needs to know. The comments should usually include at least:
5
+------------------------------------------------------------------------
6
+
7
+PROJECT TITLE:
8
+PURPOSE OF PROJECT:
9
+VERSION or DATE:
10
+HOW TO START THIS PROJECT:
11
+AUTHORS:
12
+USER INSTRUCTIONS:

binární
StringParser.class Zobrazit soubor


+ 34
- 0
StringParser.ctxt Zobrazit soubor

@@ -0,0 +1,34 @@
1
+#BlueJ class context
2
+comment0.target=StringParser
3
+comment0.text=\n\ An\ introduction\ to\ Strings\ and\ String\ methods.\n\n\ @author\ Wilhem\ Alcivar\n
4
+comment1.params=s
5
+comment1.target=java.lang.String\ upperCaseString(java.lang.String)
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
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
10
+comment2.params=s
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
13
+comment3.params=s
14
+comment3.target=java.lang.Character\ getFirstCharacter(java.lang.String)
15
+comment3.text=\n\ Takes\ a\ String\ and\ returns\ the\ first\ character\ of\ that\ string.\n\ E.G.\ cat\ would\ return\ c.\ Embark\ would\ return\ E.\n\n\ @param\ s\n\ @return\ String\n
16
+comment4.params=s\ n
17
+comment4.target=java.lang.Character\ getNthCharacter(java.lang.String,\ java.lang.Integer)
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
+comment5.params=s
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
22
+comment6.params=s
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
25
+comment7.params=s
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
28
+comment8.params=s
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
31
+comment9.params=s1\ s2
32
+comment9.target=java.lang.Boolean\ isEqual(java.lang.String,\ java.lang.String)
33
+comment9.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\ false.\ \n\ Dog\ and\ Dog\ would\ return\ true\n\n\ @param\ s1\n\ @param\ s2\n\ @return\ String\n
34
+numComments=11

+ 128
- 0
StringParser.java Zobrazit soubor

@@ -0,0 +1,128 @@
1
+
2
+/**
3
+ * An introduction to Strings and String methods.
4
+ *
5
+ * @author Wilhem Alcivar
6
+ */
7
+public class StringParser
8
+{
9
+    /**
10
+     * Takes a String and returns that String with all characters uppercased.
11
+     * E.G. cat would become CAT. dOnUt would become DONUT.
12
+     *
13
+     * @param s
14
+     * @return String
15
+     */
16
+    public static String upperCaseString(String s)
17
+    {
18
+        return null;
19
+    }
20
+
21
+    /**
22
+     * Takes a String and returns that String with all characters lowercased.
23
+     * E.G. MOUSE would become mouse. dOnUt would become donut.
24
+     *
25
+     * @param s
26
+     * @return String
27
+     */
28
+    public static String lowerCaseString(String s) {
29
+        return null;
30
+    }
31
+
32
+    /**
33
+     * Takes a String and returns the first character of that string.
34
+     * E.G. cat would return c. Embark would return E.
35
+     *
36
+     * @param s
37
+     * @return String
38
+     */
39
+    public static Character getFirstCharacter(String s) {
40
+        return null;
41
+    }
42
+
43
+    /**
44
+     * Takes a String and returns the character at index n of that string.
45
+     * E.G. cat, 2 would return t. Embark, 4 would return r.
46
+     *
47
+     * @param s
48
+     * @param n
49
+     * @return String
50
+     */
51
+    public static Character getNthCharacter(String s, Integer n) {
52
+        return null;
53
+    }
54
+
55
+    /**
56
+     * Takes a String and returns that string with the first character uppercased.
57
+     * E.G. cat would return Cat. cofFee would return CofFee.
58
+     *
59
+     * @param s
60
+     * @return String
61
+     */
62
+    public static String upperCaseFirstCharacter(String s) {
63
+        return null;
64
+    }
65
+
66
+    /**
67
+     * Takes a String and returns that string with the first character of each word in it uppercased
68
+     * and then joined.
69
+     * E.G. dog whistle would return DogWhistle. adjuNCT pRoFessOR would return AdjuctProfessor.
70
+     *
71
+     * @param s
72
+     * @return String
73
+     */
74
+    public static String camelCaseString(String s) {
75
+        return null;
76
+    }
77
+
78
+    /**
79
+     * Takes a String and returns that string with each character lowercased
80
+     * and then joined with an underscore
81
+     * E.G. dog whistle would return dog_whistle. adjuNCT pRoFessOR would return adjuct_professor.
82
+     *
83
+     * @param s
84
+     * @return String
85
+     */
86
+    public static String snakeCaseString(String s) {
87
+        return null;
88
+    }
89
+
90
+    /**
91
+     * Takes a String and returns the length of that string
92
+     * E.G. cat would return 3. extra would return 5.
93
+     *
94
+     * @param s
95
+     * @return String
96
+     */
97
+    public static Integer getLength(String s) {
98
+        return null;
99
+    }
100
+
101
+    /**
102
+     * Takes in two strings and returns true if they are equal
103
+     * E.G. example and shelf would return false. 
104
+     * cat and CaT would return false. 
105
+     * Dog and Dog would return true
106
+     *
107
+     * @param s1
108
+     * @param s2
109
+     * @return String
110
+     */
111
+    public static Boolean isEqual(String s1, String s2) {
112
+        return null;
113
+    }
114
+
115
+    /**
116
+     * Takes in two strings and returns true if they are equal
117
+     * E.G. example and shelf would return false. 
118
+     * cat and CaT would return true. 
119
+     * Dog and Dog would return true
120
+     *
121
+     * @param s1
122
+     * @param s2
123
+     * @return String
124
+     */
125
+    public static Boolean isEqualIgnoreCase(String s1, String s2) {
126
+        return null;
127
+    }
128
+}

binární
StringParserTest.class Zobrazit soubor


+ 23
- 0
StringParserTest.ctxt Zobrazit soubor

@@ -0,0 +1,23 @@
1
+#BlueJ class context
2
+comment0.target=StringParserTest
3
+comment1.params=
4
+comment1.target=void\ upperCaseString()
5
+comment10.params=
6
+comment10.target=void\ isEqualIgnoreCase()
7
+comment2.params=
8
+comment2.target=void\ lowerCaseString()
9
+comment3.params=
10
+comment3.target=void\ getFirstCharacter()
11
+comment4.params=
12
+comment4.target=void\ getNthCharacter()
13
+comment5.params=
14
+comment5.target=void\ upperCaseFirstCharacter()
15
+comment6.params=
16
+comment6.target=void\ camelCaseString()
17
+comment7.params=
18
+comment7.target=void\ snakeCaseString()
19
+comment8.params=
20
+comment8.target=void\ getLength()
21
+comment9.params=
22
+comment9.target=void\ isEqual()
23
+numComments=11

+ 162
- 0
StringParserTest.java Zobrazit soubor

@@ -0,0 +1,162 @@
1
+import org.junit.Test;
2
+
3
+import static org.junit.Assert.*;
4
+
5
+public class StringParserTest {
6
+    @Test
7
+    public void upperCaseString() {
8
+        //Given
9
+        String string1 = "test string";
10
+        String expected = "TEST STRING";
11
+
12
+        //When
13
+        String actual = StringParser.upperCaseString(string1);
14
+
15
+        //Expect
16
+        assertEquals(expected, actual);
17
+    }
18
+
19
+    @Test
20
+    public void lowerCaseString() {
21
+        //Given
22
+        String string1 = "TEST STRING";
23
+        String expected = "test string";
24
+
25
+        //When
26
+        String actual = StringParser.lowerCaseString(string1);
27
+
28
+        //Expect
29
+        assertEquals(expected, actual);
30
+    }
31
+
32
+    @Test
33
+    public void getFirstCharacter() {
34
+        //Given
35
+        String string1 = "test string";
36
+        Character expected = 't';
37
+
38
+        //When
39
+        Character actual = StringParser.getFirstCharacter(string1);
40
+
41
+        //Expect
42
+        assertEquals(expected, actual);
43
+    }
44
+
45
+    @Test
46
+    public void getNthCharacter() {
47
+        //Given
48
+        String string1 = "test string";
49
+        Integer index = 2;
50
+        Character expected = 's';
51
+
52
+        //When
53
+        Character actual = StringParser.getNthCharacter(string1, index);
54
+
55
+        //Expect
56
+        assertEquals(expected, actual);
57
+    }
58
+
59
+    @Test
60
+    public void upperCaseFirstCharacter() {
61
+        //Given
62
+        String string1 = "test string";
63
+        String expected = "Test string";
64
+
65
+        //When
66
+        String actual = StringParser.upperCaseFirstCharacter(string1);
67
+
68
+        //Expect
69
+        assertEquals(expected, actual);
70
+    }
71
+
72
+    @Test
73
+    public void camelCaseString() {
74
+        //Given
75
+        String string1 = "tEsT sTrInG";
76
+        String expected = "TestString";
77
+
78
+        //When
79
+        String actual = StringParser.camelCaseString(string1);
80
+
81
+        //Expect
82
+        assertEquals(expected, actual);
83
+    }
84
+
85
+    @Test
86
+    public void snakeCaseString() {
87
+        //Given
88
+        String string1 = "tEST STring";
89
+        String expected = "test_string";
90
+
91
+        //When
92
+        String actual = StringParser.snakeCaseString(string1);
93
+
94
+        //Expect
95
+        assertEquals(expected, actual);
96
+    }
97
+
98
+    @Test
99
+    public void getLength() {
100
+        //Given
101
+        String string1 = "A different string";
102
+        Integer expected1 = 18;
103
+
104
+        String string2 = "test string";
105
+        Integer expected2 = 11;
106
+
107
+        //When
108
+        Integer actual1 = StringParser.getLength(string1);
109
+        Integer actual2 = StringParser.getLength(string2);
110
+
111
+        //Expect
112
+        assertEquals(expected1, actual1);
113
+        assertEquals(expected2, actual2);
114
+    }
115
+
116
+    @Test
117
+    public void isEqual() {
118
+        //Given
119
+        String string1 = "A different string";
120
+        String compareString1 = "a Different string";
121
+        Boolean expected1 = false;
122
+
123
+        String string2 = "test string";
124
+        String compareString2 = "test string";
125
+        Boolean expected2 = true;
126
+
127
+        //When
128
+        Boolean actual1 = StringParser.isEqual(string1, compareString1);
129
+        Boolean actual2 = StringParser.isEqual(string2, compareString2);
130
+
131
+        //Expect
132
+        assertEquals(expected1, actual1);
133
+        assertEquals(expected2, actual2);
134
+    }
135
+
136
+    @Test
137
+    public void isEqualIgnoreCase() {
138
+        //Given
139
+        String string1 = "A different string";
140
+        String compareString1 = "a Different string";
141
+        Boolean expected1 = true;
142
+
143
+        String string2 = "test string";
144
+        String compareString2 = "test string";
145
+        Boolean expected2 = true;
146
+
147
+        String string3 = "A different string";
148
+        String compareString3 = "A different string!";
149
+        Boolean expected3 = false;
150
+
151
+
152
+        //When
153
+        Boolean actual1 = StringParser.isEqualIgnoreCase(string1, compareString1);
154
+        Boolean actual2 = StringParser.isEqualIgnoreCase(string2, compareString2);
155
+        Boolean actual3 = StringParser.isEqualIgnoreCase(string3, compareString3);
156
+
157
+        //Expect
158
+        assertEquals(expected1, actual1);
159
+        assertEquals(expected2, actual2);
160
+        assertEquals(expected3, actual3);
161
+    }
162
+}

+ 3
- 0
package.bluej Zobrazit soubor

@@ -0,0 +1,3 @@
1
+#BlueJ package file
2
+#Wed Oct 17 09:06:47 EDT 2018
3
+project.charset=UTF-8