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