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