Selaa lähdekoodia

moved java files to main folder to avoid confustion

Nhu Nguyen 6 vuotta sitten
vanhempi
commit
75de476e21

+ 240
- 0
MathUtilities.java Näytä tiedosto

@@ -0,0 +1,240 @@
1
+
2
+
3
+/**
4
+* Created by dan on 6/14/17.
5
+*/
6
+public class MathUtilities {
7
+
8
+   /**
9
+    * @param baseValue  starting value
10
+    * @param difference value to add to starting value
11
+    * @return sum of `baseValue` and `difference`
12
+    */
13
+   public Integer add(int baseValue, int difference) {
14
+       return null;
15
+   }
16
+
17
+   /**
18
+    * @param baseValue  starting value
19
+    * @param difference value to add to starting value
20
+    * @return sum of `baseValue` and `difference`
21
+    */
22
+   public Long add(long baseValue, long difference) {
23
+       return null;
24
+   }
25
+
26
+   /**
27
+    * @param baseValue  starting value
28
+    * @param difference value to add to starting value
29
+    * @return sum of `baseValue` and `difference`
30
+    */
31
+   public Short add(short baseValue, short difference) {
32
+       return null;
33
+   }
34
+
35
+   /**
36
+    * @param baseValue  starting value
37
+    * @param difference value to add to starting value
38
+    * @return sum of `baseValue` and `difference`
39
+    */
40
+   public Byte add(byte baseValue, byte difference) {
41
+       return null;
42
+   }
43
+
44
+   /**
45
+    * @param baseValue  starting value
46
+    * @param difference value to add to starting value
47
+    * @return sum of `baseValue` and `difference`
48
+    */
49
+   public Float add(float baseValue, float difference) {
50
+       return null;
51
+   }
52
+
53
+   /**
54
+    * @param baseValue  starting value
55
+    * @param difference value to add to starting value
56
+    * @return sum of `baseValue` and `difference`
57
+    */
58
+   public Double add(double baseValue, double difference) {
59
+       return null;
60
+   }
61
+
62
+   /**
63
+    * @param baseValue  starting value
64
+    * @param difference value to subtract from starting value
65
+    * @return difference between `baseValue` and `difference`
66
+    */
67
+   public Integer subtract(int baseValue, int difference) {
68
+       return null;
69
+   }
70
+
71
+   /**
72
+    * @param baseValue  starting value
73
+    * @param difference value to subtract from starting value
74
+    * @return difference between `baseValue` and `difference`
75
+    */
76
+   public Long subtract(long baseValue, long difference) {
77
+       return null;
78
+   }
79
+
80
+   /**
81
+    * @param baseValue  starting value
82
+    * @param difference value to subtract from starting value
83
+    * @return difference between `baseValue` and `difference`
84
+    */
85
+   public Short subtract(short baseValue, short difference) {
86
+       return null;
87
+   }
88
+
89
+   /**
90
+    * @param baseValue  starting value
91
+    * @param difference value to subtract from starting value
92
+    * @return difference between `baseValue` and `difference`
93
+    */
94
+   public Byte subtract(byte baseValue, byte difference) {
95
+       return null;
96
+   }
97
+
98
+   /**
99
+    * @param baseValue  starting value
100
+    * @param difference value to subtract from starting value
101
+    * @return difference between `baseValue` and `difference`
102
+    */
103
+   public Float subtract(float baseValue, float difference) {
104
+       return null;
105
+   }
106
+
107
+   /**
108
+    * @param baseValue  starting value
109
+    * @param difference value to subtract from starting value
110
+    * @return difference between `baseValue` and `difference`
111
+    */
112
+   public Double subtract(double baseValue, double difference) {
113
+       return null;
114
+   }
115
+
116
+
117
+   /**
118
+    * @param dividend value to be divided
119
+    * @param divisor value to divide by
120
+    * @return division of `dividend` by `divisor
121
+    */
122
+   public Integer divide(int dividend, int divisor) {
123
+       return null;
124
+   }
125
+
126
+   /**
127
+    * @param dividend value to be divided
128
+    * @param divisor value to divide by
129
+    * @return division of `dividend` by `divisor
130
+    */
131
+   public Long divide(long dividend, long divisor) {
132
+       return null;
133
+   }
134
+
135
+   /**
136
+    * @param dividend value to be divided
137
+    * @param divisor value to divide by
138
+    * @return division of `dividend` by `divisor
139
+    */
140
+   public Short divide(short dividend, short divisor) {
141
+       return null;
142
+   }
143
+
144
+   /**
145
+    * @param dividend value to be divided
146
+    * @param divisor value to divide by
147
+    * @return division of `dividend` by `divisor
148
+    */
149
+   public Byte divide(byte dividend, byte divisor) {
150
+       return null;
151
+   }
152
+
153
+   /**
154
+    * @param dividend value to be divided
155
+    * @param divisor value to divide by
156
+    * @return division of `dividend` by `divisor
157
+    */
158
+   public Float divide(float dividend, float divisor) {
159
+       return null;
160
+   }
161
+
162
+   /**
163
+    * @param dividend value to be divided
164
+    * @param divisor value to divide by
165
+    * @return division of `dividend` by `divisor
166
+    */
167
+   public Double divide(double dividend, double divisor) {
168
+       return null;
169
+   }
170
+
171
+
172
+   /**
173
+    * @param multiplicand value to be multiplied
174
+    * @param multiplier value to multiply by
175
+    * @return product of `multiplicand` by `multiplier`
176
+    */
177
+   public Integer multiply(int multiplicand, int multiplier) {
178
+       return null;
179
+   }
180
+
181
+   /**
182
+    * @param multiplicand value to be multiplied
183
+    * @param multiplier value to multiply by
184
+    * @return product of `multiplicand` by `multiplier`
185
+    */
186
+   public Long multiply(long multiplicand, long multiplier) {
187
+       return null;
188
+   }
189
+
190
+   /**
191
+    * @param multiplicand value to be multiplied
192
+    * @param multiplier value to multiply by
193
+    * @return product of `multiplicand` by `multiplier`
194
+    */
195
+   public Short multiply(short multiplicand, short multiplier) {
196
+       return null;
197
+   }
198
+   /**
199
+    * @param multiplicand value to be multiplied
200
+    * @param multiplier value to multiply by
201
+    * @return product of `multiplicand` by `multiplier`
202
+    */
203
+   public Byte multiply(byte multiplicand, byte multiplier) {
204
+       return null;
205
+   }
206
+
207
+   /**
208
+    * @param multiplicand value to be multiplied
209
+    * @param multiplier value to multiply by
210
+    * @return product of `multiplicand` by `multiplier`
211
+    */
212
+   public Float multiply(float multiplicand, float multiplier) {
213
+       return null;
214
+   }
215
+
216
+   /**
217
+    * @param multiplicand value to be multiplied
218
+    * @param multiplier value to multiply by
219
+    * @return product of `multiplicand` by `multiplier`
220
+    */
221
+   public Double multiply(double multiplicand, double multiplier) {
222
+       return null;
223
+   }
224
+
225
+
226
+   /**
227
+     * @return true
228
+    */
229
+   public Boolean returnTrue() {
230
+       return null;
231
+   }
232
+
233
+   /**
234
+    * @return false
235
+    */
236
+   public Boolean returnFalse() {
237
+       return null;
238
+   }
239
+
240
+}

Method Fundamentals/MathUtilitiesTest.java → MathUtilitiesTest.java Näytä tiedosto

@@ -14,14 +14,6 @@ import org.junit.Test;
14 14
 public class MathUtilitiesTest
15 15
 {
16 16
     private MathUtilities primativeTypes;
17
-          
18
-    /**
19
-     * Default constructor for test class MathUtilitiesTest
20
-     */
21
-    public MathUtilitiesTest()
22
-    {
23
-        primativeTypes = new MathUtilities();
24
-    }
25 17
 
26 18
     /**
27 19
      * Sets up the test fixture.
@@ -29,8 +21,8 @@ public class MathUtilitiesTest
29 21
      * Called before every test case method.
30 22
      */
31 23
     @Before
32
-    public void setUp()
33
-    {
24
+    public void setUp(){
25
+        primativeTypes = new MathUtilities();
34 26
     }
35 27
 
36 28
     /**
@@ -287,7 +279,7 @@ public class MathUtilitiesTest
287 279
         // : Given
288 280
         byte multiplicand = 16;
289 281
         byte multiplier = 14;
290
-        byte expectedByte = 64;
282
+        byte expectedByte = -32;
291 283
         // : When
292 284
         byte actualByte = primativeTypes.multiply(multiplicand, multiplier);
293 285
         // : Then

+ 0
- 240
Method Fundamentals/MathUtilities.java Näytä tiedosto

@@ -1,240 +0,0 @@
1
- 
2
-
3
-/**
4
- * Created by dan on 6/14/17.
5
- */
6
-public class MathUtilities {
7
-
8
-    /**
9
-     * @param baseValue  starting value
10
-     * @param difference value to add to starting value
11
-     * @return sum of `baseValue` and `difference`
12
-     */
13
-    public Integer add(int baseValue, int difference) {
14
-        return null;
15
-    }
16
-
17
-    /**
18
-     * @param baseValue  starting value
19
-     * @param difference value to add to starting value
20
-     * @return sum of `baseValue` and `difference`
21
-     */
22
-    public Long add(long baseValue, long difference) {
23
-        return null;
24
-    }
25
-
26
-    /**
27
-     * @param baseValue  starting value
28
-     * @param difference value to add to starting value
29
-     * @return sum of `baseValue` and `difference`
30
-     */
31
-    public Short add(short baseValue, short difference) {
32
-        return null;
33
-    }
34
-
35
-    /**
36
-     * @param baseValue  starting value
37
-     * @param difference value to add to starting value
38
-     * @return sum of `baseValue` and `difference`
39
-     */
40
-    public Byte add(byte baseValue, byte difference) {
41
-        return null;
42
-    }
43
-
44
-    /**
45
-     * @param baseValue  starting value
46
-     * @param difference value to add to starting value
47
-     * @return sum of `baseValue` and `difference`
48
-     */
49
-    public Float add(float baseValue, float difference) {
50
-        return null;
51
-    }
52
-
53
-    /**
54
-     * @param baseValue  starting value
55
-     * @param difference value to add to starting value
56
-     * @return sum of `baseValue` and `difference`
57
-     */
58
-    public Double add(double baseValue, double difference) {
59
-        return null;
60
-    }
61
-
62
-    /**
63
-     * @param baseValue  starting value
64
-     * @param difference value to subtract from starting value
65
-     * @return difference between `baseValue` and `difference`
66
-     */
67
-    public Integer subtract(int baseValue, int difference) {
68
-        return null;
69
-    }
70
-
71
-    /**
72
-     * @param baseValue  starting value
73
-     * @param difference value to subtract from starting value
74
-     * @return difference between `baseValue` and `difference`
75
-     */
76
-    public Long subtract(long baseValue, long difference) {
77
-        return null;
78
-    }
79
-
80
-    /**
81
-     * @param baseValue  starting value
82
-     * @param difference value to subtract from starting value
83
-     * @return difference between `baseValue` and `difference`
84
-     */
85
-    public Short subtract(short baseValue, short difference) {
86
-        return null;
87
-    }
88
-
89
-    /**
90
-     * @param baseValue  starting value
91
-     * @param difference value to subtract from starting value
92
-     * @return difference between `baseValue` and `difference`
93
-     */
94
-    public Byte subtract(byte baseValue, byte difference) {
95
-        return null;
96
-    }
97
-
98
-    /**
99
-     * @param baseValue  starting value
100
-     * @param difference value to subtract from starting value
101
-     * @return difference between `baseValue` and `difference`
102
-     */
103
-    public Float subtract(float baseValue, float difference) {
104
-        return null;
105
-    }
106
-
107
-    /**
108
-     * @param baseValue  starting value
109
-     * @param difference value to subtract from starting value
110
-     * @return difference between `baseValue` and `difference`
111
-     */
112
-    public Double subtract(double baseValue, double difference) {
113
-        return null;
114
-    }
115
-
116
-
117
-    /**
118
-     * @param dividend value to be divided
119
-     * @param divisor value to divide by
120
-     * @return division of `dividend` by `divisor
121
-     */
122
-    public Integer divide(int dividend, int divisor) {
123
-        return null;
124
-    }
125
-
126
-    /**
127
-     * @param dividend value to be divided
128
-     * @param divisor value to divide by
129
-     * @return division of `dividend` by `divisor
130
-     */
131
-    public Long divide(long dividend, long divisor) {
132
-        return null;
133
-    }
134
-
135
-    /**
136
-     * @param dividend value to be divided
137
-     * @param divisor value to divide by
138
-     * @return division of `dividend` by `divisor
139
-     */
140
-    public Short divide(short dividend, short divisor) {
141
-        return null;
142
-    }
143
-
144
-    /**
145
-     * @param dividend value to be divided
146
-     * @param divisor value to divide by
147
-     * @return division of `dividend` by `divisor
148
-     */
149
-    public Byte divide(byte dividend, byte divisor) {
150
-        return null;
151
-    }
152
-
153
-    /**
154
-     * @param dividend value to be divided
155
-     * @param divisor value to divide by
156
-     * @return division of `dividend` by `divisor
157
-     */
158
-    public Float divide(float dividend, float divisor) {
159
-        return null;
160
-    }
161
-
162
-    /**
163
-     * @param dividend value to be divided
164
-     * @param divisor value to divide by
165
-     * @return division of `dividend` by `divisor
166
-     */
167
-    public Double divide(double dividend, double divisor) {
168
-        return null;
169
-    }
170
-
171
-
172
-    /**
173
-     * @param multiplicand value to be multiplied
174
-     * @param multiplier value to multiply by
175
-     * @return product of `multiplicand` by `multiplier`
176
-     */
177
-    public Integer multiply(int multiplicand, int multiplier) {
178
-        return null;
179
-    }
180
-
181
-    /**
182
-     * @param multiplicand value to be multiplied
183
-     * @param multiplier value to multiply by
184
-     * @return product of `multiplicand` by `multiplier`
185
-     */
186
-    public Long multiply(long multiplicand, long multiplier) {
187
-        return null;
188
-    }
189
-
190
-    /**
191
-     * @param multiplicand value to be multiplied
192
-     * @param multiplier value to multiply by
193
-     * @return product of `multiplicand` by `multiplier`
194
-     */
195
-    public Short multiply(short multiplicand, short multiplier) {
196
-        return null;
197
-    }
198
-    /**
199
-     * @param multiplicand value to be multiplied
200
-     * @param multiplier value to multiply by
201
-     * @return product of `multiplicand` by `multiplier`
202
-     */
203
-    public Byte multiply(byte multiplicand, byte multiplier) {
204
-        return null;
205
-    }
206
-
207
-    /**
208
-     * @param multiplicand value to be multiplied
209
-     * @param multiplier value to multiply by
210
-     * @return product of `multiplicand` by `multiplier`
211
-     */
212
-    public Float multiply(float multiplicand, float multiplier) {
213
-        return null;
214
-    }
215
-
216
-    /**
217
-     * @param multiplicand value to be multiplied
218
-     * @param multiplier value to multiply by
219
-     * @return product of `multiplicand` by `multiplier`
220
-     */
221
-    public Double multiply(double multiplicand, double multiplier) {
222
-        return null;
223
-    }
224
-
225
-
226
-    /**
227
-      * @return true
228
-     */
229
-    public Boolean returnTrue() {
230
-        return null;
231
-    }
232
-
233
-    /**
234
-     * @return false
235
-     */
236
-    public Boolean returnFalse() {
237
-        return null;
238
-    }
239
-
240
-}

+ 0
- 42
Method Fundamentals/PredicateUtilities.java Näytä tiedosto

@@ -1,42 +0,0 @@
1
- 
2
-
3
-/**
4
- * Created by dan on 6/14/17.
5
- */
6
-public class PredicateUtilities {
7
-    /**
8
-     * @param x
9
-     * @param y
10
-     * @return true if `x` is greater than `y`
11
-     */
12
-    public Boolean isGreaterThan(int x, int y) {
13
-        return null;
14
-    }
15
-
16
-    /**
17
-     * @param x
18
-     * @param y
19
-     * @return true if `x` is less than `y`
20
-     */
21
-    public Boolean isLessThan(int x, int y) {
22
-        return null;
23
-    }
24
-
25
-    /**
26
-     * @param x
27
-     * @param y
28
-     * @return true if `x` is greater than or equal to `y`
29
-     */
30
-    public Boolean isGreaterThanOrEqualTo(int x, int y) {
31
-        return null;
32
-    }
33
-
34
-    /**
35
-     * @param x
36
-     * @param y
37
-     * @return true if `x` is less than or equal to `y`
38
-     */
39
-    public Boolean isLessThanOrEqualTo(int x, int y) {
40
-        return null;
41
-    }
42
-}

+ 0
- 103
Method Fundamentals/README.TXT Näytä tiedosto

@@ -1,103 +0,0 @@
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: Java Fundamentals
8
-PURPOSE OF PROJECT:
9
-VERSION or DATE:
10
-HOW TO START THIS PROJECT:
11
-AUTHORS:
12
-USER INSTRUCTIONS:
13
-
14
-From here on down, this file is in MarkDown format. (Look it up. Use the Github version.)
15
-# Java Fundamentals
16
-
17
-### **Objective:**
18
-* To complete the method stubs in each of the provided classes
19
-	* `MathUtilities`
20
-	* `PredicateUtilities`
21
-	* `StringUtilities`
22
-
23
-### **Purpose:**
24
-* To establish familiarity with
25
-    * [primitive data-types](http://cs.fit.edu/~ryan/java/language/java-data.html)
26
-    * [method signatures and return statements](http://www.homeandlearn.co.uk/java/java_methods.html)
27
-    * [String operations](https://www.tutorialspoint.com/java/java_strings.htm)
28
-    
29
-### **Classes to be completed:**
30
-* `MathUtilities`
31
-* `PredicateUtilities`
32
-* `StringUtilities`
33
-	
34
-### **Instructions:**
35
-
36
-1. Fork this Repository
37
-    * [fork](https://help.github.com/articles/fork-a-repo/) this repository to your personal github account 
38
-    * [clone](https://help.github.com/articles/cloning-a-repository/) **your** `forked` repository to your local machine.
39
-    * Complete steps 2 and 3  
40
-    * `git add` your changes to the list of your `commited` files.
41
-    * `git commit` your added files to the list of your `staged` files.
42
-    * `git push` your staged files to your remote repository.
43
-    * submit a `pull request` which compares Zipcoder `master` to your `master`.
44
-2. Complete each of the method stubs in each of the `main` classes provided.
45
-    * There are comments above each method stub to describe the expected behavior.
46
-3. Make sure you Run Tests
47
-
48
-
49
-## Predicate Utilities
50
-* A _predicate_ is a clause which states something about a subject. (_e.g., **is assigning**_ in _"Leon **is assigning** homework"_)
51
-* Ensure each of the test cases passes successfully in the class [PredicateUtilitiesTest](https://git.zipcode.rocks/ZipCodeWilmington/ZCW-Lab-Fundamental-Methods/src/branch/master/Method%20Fundamentals/PredicateUtilitiesTest.java) by completing each of the method stubs in the class [PredicateUtilities](https://git.zipcode.rocks/ZipCodeWilmington/ZCW-Lab-Fundamental-Methods/src/branch/master/Method%20Fundamentals/PredicateUtilities.java).
52
-* Method Stubs to be completed
53
-	* `boolean isGreaterThan(int x, int y)`
54
-	* `boolean isLessThan(int x, int y)`
55
-	* `boolean isGreaterThanOrEqualTo(int x, int y)`
56
-	* `boolean isLessThanOrEqualTo(int x, int y)`
57
-
58
-
59
-## Math Utilities
60
-* Ensure each of the test cases passes successfully in the class [MathUtilitiesTest](https://git.zipcode.rocks/ZipCodeWilmington/ZCW-Lab-Fundamental-Methods/src/branch/master/Method%20Fundamentals/TestMathUtilities.java) by completing each of the method stubs in the class [MathUtilities](https://git.zipcode.rocks/ZipCodeWilmington/ZCW-Lab-Fundamental-Methods/src/branch/master/Method%20Fundamentals/MathUtilities.java).
61
-* Method Stubs to be completed	
62
-	* `Integer add(int, int)`
63
-	* `Long add(long, long)`
64
-	* `Short add(short, short)`
65
-	* `Byte add(byte, byte)`
66
-	* `Float add(float, float)`
67
-	* `Double add(double, double)`
68
-	* `Integer subtract(int, int)`
69
-	* `Long subtract(long, long)`
70
-	* `Short subtract(short, short)`
71
-	* `Byte subtract(byte, byte)`
72
-	* `Float subtract(float, float)`
73
-	* `Double subtract(double, double)`
74
-	* `Integer divide(int, int)`
75
-	* `Long divide(long, long)`
76
-	* `Short divide(short, short)`
77
-	* `Byte divide(byte, byte)`
78
-	* `Float divide(float, float)`
79
-	* `Double divide(double, double)`
80
-	* `Integer multiply(int, int)`
81
-	* `Long multiply(long, long)`
82
-	* `Short multiply(short, short)`
83
-	* `Byte multiply(byte, byte)`
84
-	* `Float multiply(float, float)`
85
-	* `Double multiply(double, double)`
86
-	* `Boolean returnTrue`
87
-	* `Boolean returnFalse`
88
-
89
-
90
-## String Utilities
91
-* Ensure each of the test cases passes successfully in the class [StringUtilitiesTest](https://git.zipcode.rocks/ZipCodeWilmington/ZCW-Lab-Fundamental-Methods/src/branch/master/Method%20Fundamentals/StringUtilitiesTest.java) by completing each of the method stubs in the class [StringUtilities](https://git.zipcode.rocks/ZipCodeWilmington/ZCW-Lab-Fundamental-Methods/src/branch/master/Method%20Fundamentals/StringUtilities.java).
92
-* Method Stubs to be completed
93
-	* `String concatenation(String, String)`
94
-	* `String concatenation(int, String)`
95
-	* `String getPrefix(String)`
96
-	* `String getSuffix(String)`
97
-	* `Boolean compareTwoStrings(String)`
98
-	* `Character getMiddleCharacter(String)`
99
-	* `String getFirstWord(String)`
100
-	* `String getSecondWord(String)`
101
-	* `String reverse(String)`
102
-	
103
-

+ 42
- 0
PredicateUtilities.java Näytä tiedosto

@@ -0,0 +1,42 @@
1
+
2
+
3
+/**
4
+* Created by dan on 6/14/17.
5
+*/
6
+public class PredicateUtilities {
7
+   /**
8
+    * @param x
9
+    * @param y
10
+    * @return true if `x` is greater than `y`
11
+    */
12
+   public Boolean isGreaterThan(int x, int y) {
13
+       return null;
14
+   }
15
+
16
+   /**
17
+    * @param x
18
+    * @param y
19
+    * @return true if `x` is less than `y`
20
+    */
21
+   public Boolean isLessThan(int x, int y) {
22
+       return null;
23
+   }
24
+
25
+   /**
26
+    * @param x
27
+    * @param y
28
+    * @return true if `x` is greater than or equal to `y`
29
+    */
30
+   public Boolean isGreaterThanOrEqualTo(int x, int y) {
31
+       return null;
32
+   }
33
+
34
+   /**
35
+    * @param x
36
+    * @param y
37
+    * @return true if `x` is less than or equal to `y`
38
+    */
39
+   public Boolean isLessThanOrEqualTo(int x, int y) {
40
+       return null;
41
+   }
42
+}

Method Fundamentals/PredicateUtilitiesTest.java → PredicateUtilitiesTest.java Näytä tiedosto

@@ -14,13 +14,6 @@ import org.junit.Test;
14 14
 public class PredicateUtilitiesTest
15 15
 {
16 16
     private PredicateUtilities math;
17
-    /**
18
-     * Default constructor for test class PredicateUtilitiesTest
19
-     */
20
-    public PredicateUtilitiesTest()
21
-    {
22
-        math = new PredicateUtilities();
23
-    }
24 17
 
25 18
     /**
26 19
      * Sets up the test fixture.
@@ -30,16 +23,7 @@ public class PredicateUtilitiesTest
30 23
     @Before
31 24
     public void setUp()
32 25
     {
33
-    }
34
-
35
-    /**
36
-     * Tears down the test fixture.
37
-     *
38
-     * Called after every test case method.
39
-     */
40
-    @After
41
-    public void tearDown()
42
-    {
26
+        math = new PredicateUtilities();
43 27
     }
44 28
 
45 29
     @Test

Method Fundamentals/StringUtilities.java → StringUtilities.java Näytä tiedosto

@@ -1,4 +1,4 @@
1
- 
1
+
2 2
 
3 3
 /**
4 4
  * Created by dan on 6/14/17.
@@ -7,7 +7,7 @@ public class StringUtilities {
7 7
     /**
8 8
      * @return `Hello World` as a string
9 9
      */
10
-    public static String getHelloWorld() {
10
+    public String getHelloWorld() {
11 11
         return null;
12 12
     }
13 13
 
@@ -16,7 +16,7 @@ public class StringUtilities {
16 16
      * @param secondSegment a string to add
17 17
      * @return the concatenation of two strings, `firstSegment`, and `secondSegment`
18 18
      */
19
-    public static String concatenation(String firstSegment, String secondSegment){
19
+    public String concatenation(String firstSegment, String secondSegment){
20 20
         return null;
21 21
     }
22 22
 
@@ -25,7 +25,7 @@ public class StringUtilities {
25 25
      * @param secondSegment a string to add
26 26
      * @return the concatenation of an integer, `firstSegment`, and a String, `secondSegment`
27 27
      */
28
-    public static String concatenation(int firstSegment, String secondSegment){
28
+    public String concatenation(int firstSegment, String secondSegment){
29 29
         return null;
30 30
     }
31 31
 
@@ -33,7 +33,7 @@ public class StringUtilities {
33 33
      * @param input a string to be manipulated
34 34
      * @return the first 3 characters of `input`
35 35
      */
36
-    public static String getPrefix(String input){
36
+    public String getPrefix(String input){
37 37
         return null;
38 38
     }
39 39
 
@@ -41,7 +41,7 @@ public class StringUtilities {
41 41
      * @param input a string to be manipulated
42 42
      * @return the last 3 characters of `input`
43 43
      */
44
-    public static String getSuffix(String input){
44
+    public String getSuffix(String input){
45 45
         return null;
46 46
     }
47 47
 
@@ -50,7 +50,7 @@ public class StringUtilities {
50 50
      * @param comparableValue the value to be compared against
51 51
      * @return the equivalence of two strings, `inputValue` and `comparableValue`
52 52
      */
53
-    public static Boolean compareTwoStrings(String inputValue, String comparableValue){
53
+    public Boolean compareTwoStrings(String inputValue, String comparableValue){
54 54
         return null;
55 55
     }
56 56
 
@@ -58,7 +58,7 @@ public class StringUtilities {
58 58
      * @param inputValue the value input from user
59 59
      * @return the middle character of `inputValue`
60 60
      */
61
-    public static Character getMiddleCharacter(String inputValue){
61
+    public Character getMiddleCharacter(String inputValue){
62 62
         return null;
63 63
     }
64 64
 
@@ -66,7 +66,7 @@ public class StringUtilities {
66 66
      * @param spaceDelimitedString a string, representative of a sentence, containing spaces
67 67
      * @return the first sequence of characters
68 68
      */
69
-    public static String getFirstWord(String spaceDelimitedString){
69
+    public String getFirstWord(String spaceDelimitedString){
70 70
         return null;
71 71
     }
72 72
 
@@ -74,7 +74,7 @@ public class StringUtilities {
74 74
      * @param spaceDelimitedString a string delimited by spaces
75 75
      * @return the second word of a string delimited by spaces.
76 76
      */
77
-    public static String getSecondWord(String spaceDelimitedString){
77
+    public String getSecondWord(String spaceDelimitedString){
78 78
         return null;
79 79
     }
80 80
 
@@ -82,7 +82,23 @@ public class StringUtilities {
82 82
      * @param stringToReverse
83 83
      * @return an identical string with characters in reverse order.
84 84
      */
85
-    public static String reverse(String stringToReverse){
85
+    public String reverse(String stringToReverse){
86
+        return null;
87
+    }
88
+
89
+    /**
90
+     * @param input
91
+     * @return an identical string with spaces removed.
92
+     */
93
+    public String removeWhitespace(String input){
94
+        return null;
95
+    }
96
+
97
+    /**
98
+     * @param input
99
+     * @return an identical string with spaces in the front and end removed.
100
+     */
101
+    public String trim(String input){
86 102
         return null;
87 103
     }
88 104
 }

Method Fundamentals/StringUtilitiesTest.java → StringUtilitiesTest.java Näytä tiedosto

@@ -11,15 +11,8 @@ import org.junit.Test;
11 11
  * @author  (your name)
12 12
  * @version (a version number or a date)
13 13
  */
14
-public class StringUtilitiesTest
15
-{
16
-    /**
17
-     * Default constructor for test class StringUtilitiesTest
18
-     */
19
-    public StringUtilitiesTest()
20
-    {
21
-    }
22
-
14
+public class StringUtilitiesTest {
15
+    private StringUtilities stringUtilities;
23 16
     /**
24 17
      * Sets up the test fixture.
25 18
      *
@@ -28,6 +21,7 @@ public class StringUtilitiesTest
28 21
     @Before
29 22
     public void setUp()
30 23
     {
24
+        stringUtilities = new StringUtilities();
31 25
     }
32 26
 
33 27
     /**
@@ -39,14 +33,14 @@ public class StringUtilitiesTest
39 33
     public void tearDown()
40 34
     {
41 35
     }
42
-    
36
+
43 37
     @Test
44 38
     public void getHelloWorldTest() {
45 39
         // : Given
46 40
         String expected = "Hello World";
47 41
 
48 42
         // : When
49
-        String actual = StringUtilities.getHelloWorld();
43
+        String actual = stringUtilities.getHelloWorld();
50 44
 
51 45
         // : Then
52 46
         assertEquals(expected, actual);
@@ -61,7 +55,7 @@ public class StringUtilitiesTest
61 55
         String expected = "Hello Java";
62 56
 
63 57
         // : When
64
-        String actual = StringUtilities.concatenation(one,two);
58
+        String actual = stringUtilities.concatenation(one,two);
65 59
 
66 60
 
67 61
         // : Then
@@ -77,7 +71,7 @@ public class StringUtilitiesTest
77 71
         String expected = "1 Java";
78 72
 
79 73
         // : When
80
-        String actual = StringUtilities.concatenation(one,two);
74
+        String actual = stringUtilities.concatenation(one,two);
81 75
 
82 76
 
83 77
         // : Then
@@ -91,7 +85,7 @@ public class StringUtilitiesTest
91 85
         String expected = "Hel";
92 86
 
93 87
         // : When
94
-        String actual = StringUtilities.getPrefix(input);
88
+        String actual = stringUtilities.getPrefix(input);
95 89
 
96 90
         // : Then
97 91
         assertEquals(expected, actual);
@@ -104,7 +98,7 @@ public class StringUtilitiesTest
104 98
         String expected = "llo";
105 99
 
106 100
         // : When
107
-        String actual = StringUtilities.getSuffix("Hello");
101
+        String actual = stringUtilities.getSuffix("Hello");
108 102
 
109 103
         // : Then
110 104
         assertEquals(expected, actual);
@@ -117,7 +111,7 @@ public class StringUtilitiesTest
117 111
         String comparableValue = "Zipcode";
118 112
 
119 113
         // : When
120
-        boolean actual = StringUtilities.compareTwoStrings(inputValue, comparableValue);
114
+        boolean actual = stringUtilities.compareTwoStrings(inputValue, comparableValue);
121 115
 
122 116
         // : Then
123 117
         assertTrue(actual);
@@ -131,7 +125,7 @@ public class StringUtilitiesTest
131 125
         String comparableValue = "Zipcodee";
132 126
 
133 127
         // : When
134
-        boolean actual = StringUtilities.compareTwoStrings(inputValue, comparableValue);
128
+        boolean actual = stringUtilities.compareTwoStrings(inputValue, comparableValue);
135 129
 
136 130
         // : Then
137 131
         assertFalse(actual);
@@ -144,7 +138,7 @@ public class StringUtilitiesTest
144 138
         Character expected = 'c';
145 139
 
146 140
         // : When
147
-        Character actual = StringUtilities.getMiddleCharacter(input);
141
+        Character actual = stringUtilities.getMiddleCharacter(input);
148 142
 
149 143
         // : Then
150 144
         assertEquals(expected.toString(), actual.toString());
@@ -158,7 +152,7 @@ public class StringUtilitiesTest
158 152
         Character expected = 'c';
159 153
 
160 154
         // : When
161
-        Character actual = StringUtilities.getMiddleCharacter(input);
155
+        Character actual = stringUtilities.getMiddleCharacter(input);
162 156
 
163 157
         // : Then
164 158
         assertEquals(expected.toString(), actual.toString());
@@ -172,7 +166,7 @@ public class StringUtilitiesTest
172 166
         String expected = "Zipcode";
173 167
 
174 168
         // : When
175
-        String actual = StringUtilities.getFirstWord(input);
169
+        String actual = stringUtilities.getFirstWord(input);
176 170
 
177 171
         // : Then
178 172
         assertEquals(expected, actual);
@@ -186,7 +180,7 @@ public class StringUtilitiesTest
186 180
         String expected = "Wilmington";
187 181
 
188 182
         // : When
189
-        String actual = StringUtilities.getSecondWord(input);
183
+        String actual = stringUtilities.getSecondWord(input);
190 184
 
191 185
         // : Then
192 186
         assertEquals(expected, actual);
@@ -200,7 +194,33 @@ public class StringUtilitiesTest
200 194
 
201 195
 
202 196
         // : When
203
-        String actual = StringUtilities.reverse(input);
197
+        String actual = stringUtilities.reverse(input);
198
+
199
+        // : Then
200
+        assertEquals(expected, actual);
201
+    }
202
+
203
+    @Test
204
+    public void removeWhitespace(){
205
+        // : Given
206
+        String input = "It's a beautiful day in this neighborhood";
207
+        String expected = "It'sabeautifuldayinthisneighborhood";
208
+
209
+        // : When
210
+        String actual = stringUtilities.removeWhitespace(input);
211
+
212
+        // : Then
213
+        assertEquals(expected, actual);
214
+    }
215
+
216
+    @Test
217
+    public void trimWhitespaceInTheBegginningAndEnd(){
218
+        // : Given
219
+        String input = "    Zipcode Wilmington ";
220
+        String expected = "Zipcode Wilmington";
221
+
222
+        // : When
223
+        String actual = stringUtilities.trim(input);
204 224
 
205 225
         // : Then
206 226
         assertEquals(expected, actual);

Method Fundamentals/package.bluej → package.bluej Näytä tiedosto

@@ -1,25 +1,25 @@
1 1
 #BlueJ package file
2
-dependency1.from=MathUtilitiesTest
3
-dependency1.to=MathUtilities
2
+dependency1.from=StringUtilitiesTest
3
+dependency1.to=StringUtilities
4 4
 dependency1.type=UsesDependency
5 5
 dependency2.from=PredicateUtilitiesTest
6 6
 dependency2.to=PredicateUtilities
7 7
 dependency2.type=UsesDependency
8
-dependency3.from=StringUtilitiesTest
9
-dependency3.to=StringUtilities
8
+dependency3.from=MathUtilitiesTest
9
+dependency3.to=MathUtilities
10 10
 dependency3.type=UsesDependency
11
-editor.fx.0.height=910
12
-editor.fx.0.width=1113
13
-editor.fx.0.x=703
14
-editor.fx.0.y=29
15
-objectbench.height=101
16
-objectbench.width=461
11
+editor.fx.0.height=0
12
+editor.fx.0.width=0
13
+editor.fx.0.x=0
14
+editor.fx.0.y=0
15
+objectbench.height=145
16
+objectbench.width=776
17 17
 package.divider.horizontal=0.6
18
-package.divider.vertical=0.8007380073800738
19
-package.editor.height=427
18
+package.divider.vertical=0.7195571955719557
19
+package.editor.height=383
20 20
 package.editor.width=674
21
-package.editor.x=72
22
-package.editor.y=71
21
+package.editor.x=29
22
+package.editor.y=132
23 23
 package.frame.height=600
24 24
 package.frame.width=800
25 25
 package.numDependencies=3
@@ -55,21 +55,21 @@ target3.type=ClassTarget
55 55
 target3.width=100
56 56
 target3.x=20
57 57
 target3.y=130
58
+target4.association=StringUtilitiesTest
58 59
 target4.height=50
59
-target4.name=PredicateUtilitiesTest
60
+target4.name=StringUtilities
60 61
 target4.showInterface=false
61
-target4.type=UnitTestTargetJunit4
62
-target4.width=130
63
-target4.x=210
64
-target4.y=100
65
-target5.association=StringUtilitiesTest
62
+target4.type=ClassTarget
63
+target4.width=110
64
+target4.x=370
65
+target4.y=130
66 66
 target5.height=50
67
-target5.name=StringUtilities
67
+target5.name=PredicateUtilitiesTest
68 68
 target5.showInterface=false
69
-target5.type=ClassTarget
70
-target5.width=110
71
-target5.x=370
72
-target5.y=130
69
+target5.type=UnitTestTargetJunit4
70
+target5.width=130
71
+target5.x=210
72
+target5.y=100
73 73
 target6.height=50
74 74
 target6.name=MathUtilitiesTest
75 75
 target6.showInterface=false