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