Parcourir la source

I'm goooooing through changes

Mitch Taylor il y a 6 ans
Parent
révision
6aca2c9cf8

+ 2
- 0
ChapterOneMicro.iml Voir le fichier

@@ -12,5 +12,7 @@
12 12
     <orderEntry type="sourceFolder" forTests="false" />
13 13
     <orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
14 14
     <orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
15
+    <orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
16
+    <orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
15 17
   </component>
16 18
 </module>

+ 29
- 155
src/main/java/com/zipcodewilmington/danny_do_better_exercises/MathUtilities.java Voir le fichier

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

+ 6
- 24
src/main/java/com/zipcodewilmington/danny_do_better_exercises/PredicateUtilities.java Voir le fichier

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

+ 7
- 10
src/main/java/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.java Voir le fichier

@@ -1,14 +1,14 @@
1 1
 package com.zipcodewilmington.danny_do_better_exercises;
2 2
 
3
+
3 4
 /**
4 5
  * Created by dan on 6/14/17.
5 6
  */
6 7
 public class StringUtilities {
7
-    /**
8
-     * @return `Hello World` as a string
9
-     */
8
+
10 9
     public static String getHelloWorld() {
11
-        return null;
10
+        String ayMane = "Hello World";
11
+        return ayMane;
12 12
     }
13 13
 
14 14
     /**
@@ -75,14 +75,11 @@ public class StringUtilities {
75 75
      * @return the second word of a string delimited by spaces.
76 76
      */
77 77
     public static String getSecondWord(String spaceDelimitedString){
78
-        return null;
78
+        String[] probablyWilmington = spaceDelimitedString.split("\\s+");
79
+        return probablyWilmington[1];
79 80
     }
80 81
 
81
-    /**
82
-     * @param stringToReverse
83
-     * @return an identical string with characters in reverse order.
84
-     */
85 82
     public static String reverseTheTwo(String stringToReverse){
86
-        return null;
83
+        return new StringBuilder(stringToReverse).reverse().toString();
87 84
     }
88 85
 }

BIN
target/classes/com/zipcodewilmington/danny_do_better_exercises/MathUtilities.class Voir le fichier


BIN
target/classes/com/zipcodewilmington/danny_do_better_exercises/PredicateUtilities.class Voir le fichier


BIN
target/classes/com/zipcodewilmington/danny_do_better_exercises/StringUtilities.class Voir le fichier