|
@@ -1,163 +1,119 @@
|
1
|
1
|
package com.zipcodewilmington.danny_do_better_exercises;
|
2
|
2
|
|
3
|
3
|
/**
|
4
|
|
- * Created by dan on 6/14/17.
|
|
4
|
+ * Refactored
|
5
|
5
|
*/
|
6
|
6
|
public class MathUtilities {
|
7
|
7
|
|
8
|
|
-
|
9
|
8
|
public Integer add(int baseValue, int difference) {
|
10
|
|
- int add = baseValue + difference;
|
11
|
|
- return add;
|
|
9
|
+ return baseValue + difference;
|
12
|
10
|
}
|
13
|
11
|
|
14
|
12
|
public Long add(long baseValue, long difference) {
|
15
|
|
- long add = baseValue + difference;
|
16
|
|
- return add;
|
|
13
|
+ return baseValue + difference;
|
17
|
14
|
}
|
18
|
15
|
|
19
|
16
|
public Short add(short baseValue, short difference) {
|
20
|
17
|
int sum = baseValue + difference;
|
21
|
|
- short shortSum = (short) sum;
|
22
|
|
- return shortSum;
|
|
18
|
+ return (short) sum;
|
23
|
19
|
}
|
24
|
20
|
|
25
|
21
|
public Byte add(byte baseValue, byte difference) {
|
26
|
22
|
int sum = baseValue + difference;
|
27
|
|
- byte byteSum = (byte) sum;
|
28
|
|
- return byteSum;
|
|
23
|
+ return (byte) sum;
|
29
|
24
|
}
|
30
|
25
|
|
31
|
26
|
public Float add(float baseValue, float difference) {
|
32
|
|
- float add = baseValue + difference;
|
33
|
|
- return add;
|
|
27
|
+ return baseValue + difference;
|
34
|
28
|
}
|
35
|
29
|
|
36
|
30
|
public Double add(double baseValue, double difference) {
|
37
|
|
- double add = baseValue + difference;
|
38
|
|
- return add;
|
|
31
|
+ return baseValue + difference;
|
39
|
32
|
}
|
40
|
33
|
|
41
|
34
|
public Integer subtract(int baseValue, int difference) {
|
42
|
|
- int subtract = baseValue - difference;
|
43
|
|
- return subtract;
|
|
35
|
+ return baseValue - difference;
|
44
|
36
|
}
|
45
|
37
|
|
46
|
38
|
public Long subtract(long baseValue, long difference) {
|
47
|
|
- long subtract = baseValue - difference;
|
48
|
|
- return subtract;
|
|
39
|
+ return baseValue - difference;
|
49
|
40
|
}
|
50
|
41
|
|
51
|
42
|
public Short subtract(short baseValue, short difference) {
|
52
|
43
|
int sum = baseValue - difference;
|
53
|
|
- short shortSum = (short) sum;
|
54
|
|
- return shortSum;
|
55
|
|
-
|
|
44
|
+ return (short) sum;
|
56
|
45
|
}
|
57
|
46
|
|
58
|
47
|
public Byte subtract(byte baseValue, byte difference) {
|
59
|
48
|
int sum = baseValue - difference;
|
60
|
|
- byte byteSum = (byte) sum;
|
61
|
|
- return byteSum;
|
62
|
|
-
|
|
49
|
+ return (byte) sum;
|
63
|
50
|
}
|
64
|
51
|
|
65
|
52
|
public Float subtract(float baseValue, float difference) {
|
66
|
|
- float subtract = baseValue - difference;
|
67
|
|
- return subtract;
|
|
53
|
+ return baseValue - difference;
|
68
|
54
|
}
|
69
|
55
|
|
70
|
56
|
public Double subtract(double baseValue, double difference) {
|
71
|
|
- double subtract = baseValue - difference;
|
72
|
|
- return subtract;
|
|
57
|
+ return baseValue - difference;
|
73
|
58
|
}
|
74
|
59
|
|
75
|
60
|
public Integer divide(int dividend, int divisor) {
|
76
|
|
- int divide = dividend / divisor;
|
77
|
|
- return divide;
|
|
61
|
+ return dividend / divisor;
|
78
|
62
|
}
|
79
|
63
|
|
80
|
64
|
public Long divide(long dividend, long divisor) {
|
81
|
|
- long divide = dividend / divisor;
|
82
|
|
- return divide;
|
83
|
|
-
|
|
65
|
+ return dividend / divisor;
|
84
|
66
|
}
|
85
|
67
|
|
86
|
68
|
public Short divide(short dividend, short divisor) {
|
87
|
69
|
int sum = dividend / divisor;
|
88
|
|
- short shortSum = (short) sum;
|
89
|
|
- return shortSum;
|
90
|
|
-
|
|
70
|
+ return (short) sum;
|
91
|
71
|
}
|
92
|
72
|
|
93
|
73
|
public Byte divide(byte dividend, byte divisor) {
|
94
|
74
|
int sum = dividend / divisor;
|
95
|
|
- byte byteSum = (byte) sum;
|
96
|
|
- return byteSum;
|
97
|
|
-
|
|
75
|
+ return (byte) sum;
|
98
|
76
|
}
|
99
|
77
|
|
100
|
78
|
public Float divide(float dividend, float divisor) {
|
101
|
|
- float divide = dividend / divisor;
|
102
|
|
- return divide;
|
103
|
|
-
|
|
79
|
+ return dividend / divisor;
|
104
|
80
|
}
|
105
|
81
|
|
106
|
82
|
public Double divide(double dividend, double divisor) {
|
107
|
|
- double divide = dividend / divisor;
|
108
|
|
- return divide;
|
109
|
|
-
|
|
83
|
+ return dividend / divisor;
|
110
|
84
|
}
|
111
|
85
|
|
112
|
86
|
public Integer multiply(int multiplicand, int multiplier) {
|
113
|
|
- int multiply = multiplicand * multiplier;
|
114
|
|
- return multiply;
|
|
87
|
+ return multiplicand * multiplier;
|
115
|
88
|
}
|
116
|
89
|
|
117
|
90
|
public Long multiply(long multiplicand, long multiplier) {
|
118
|
|
- long multiply = multiplicand * multiplier;
|
119
|
|
- return multiply;
|
|
91
|
+ return multiplicand * multiplier;
|
120
|
92
|
}
|
121
|
93
|
|
122
|
94
|
public Short multiply(short multiplicand, short multiplier) {
|
123
|
95
|
int sum = multiplicand * multiplier;
|
124
|
|
- short shortSum = (short) sum;
|
125
|
|
- return shortSum;
|
|
96
|
+ return (short) sum;
|
126
|
97
|
}
|
127
|
98
|
|
128
|
99
|
public Byte multiply(byte multiplicand, byte multiplier) {
|
129
|
100
|
int sum = multiplicand * multiplier;
|
130
|
|
- byte byteSum = (byte) sum;
|
131
|
|
- return byteSum;
|
|
101
|
+ return (byte) sum;
|
132
|
102
|
}
|
133
|
103
|
|
134
|
104
|
public Float multiply(float multiplicand, float multiplier) {
|
135
|
|
- float multiply = multiplicand * multiplier;
|
136
|
|
- return multiply;
|
|
105
|
+ return multiplicand * multiplier;
|
137
|
106
|
}
|
138
|
107
|
|
139
|
108
|
public Double multiply(double multiplicand, double multiplier) {
|
140
|
|
- double multiply = multiplicand * multiplier;
|
141
|
|
- return multiply;
|
142
|
|
-
|
|
109
|
+ return multiplicand * multiplier;
|
143
|
110
|
}
|
144
|
111
|
|
145
|
112
|
public Boolean returnTrue() {
|
146
|
|
- if (20 < 100) {
|
147
|
|
- return true;
|
148
|
|
- }
|
149
|
|
- else {
|
150
|
|
- return false;
|
151
|
|
- }
|
|
113
|
+ return true;
|
152
|
114
|
}
|
153
|
115
|
|
154
|
116
|
public Boolean returnFalse() {
|
155
|
|
- if (69 >= 9000) {
|
156
|
|
- return true;
|
157
|
|
- } else {
|
158
|
|
- return false;
|
159
|
|
- }
|
160
|
|
-
|
|
117
|
+ return false;
|
161
|
118
|
}
|
162
|
|
-
|
163
|
|
-}
|
|
119
|
+}
|