Christian Sheridan hace 6 años
padre
commit
868a6b9209

BIN
DanDoBetterDrills/MathUtilities.class Ver fichero


BIN
DanDoBetterDrills/MathUtilitiesTest.class Ver fichero


BIN
DanDoBetterDrills/PredicateUtilities.class Ver fichero


BIN
DanDoBetterDrills/PredicateUtilitiesTest.class Ver fichero


BIN
MathUtilities.class Ver fichero


+ 33
- 26
MathUtilities.java Ver fichero

@@ -1,3 +1,5 @@
1
+package DanDoBetterDrills;
2
+
1 3
  
2 4
 
3 5
 /**
@@ -11,7 +13,8 @@ public class MathUtilities {
11 13
      * @return sum of `baseValue` and `difference`
12 14
      */
13 15
     public Integer add(int baseValue, int difference) {
14
-        return null;
16
+        int easyOne = baseValue + difference;
17
+        return easyOne;
15 18
     }
16 19
 
17 20
     /**
@@ -20,7 +23,8 @@ public class MathUtilities {
20 23
      * @return sum of `baseValue` and `difference`
21 24
      */
22 25
     public Long add(long baseValue, long difference) {
23
-        return null;
26
+        long easyOne = baseValue + difference;
27
+        return easyOne;
24 28
     }
25 29
 
26 30
     /**
@@ -29,7 +33,8 @@ public class MathUtilities {
29 33
      * @return sum of `baseValue` and `difference`
30 34
      */
31 35
     public Short add(short baseValue, short difference) {
32
-        return null;
36
+        short easyOne = (short)(baseValue + difference);
37
+        return easyOne;
33 38
     }
34 39
 
35 40
     /**
@@ -38,7 +43,8 @@ public class MathUtilities {
38 43
      * @return sum of `baseValue` and `difference`
39 44
      */
40 45
     public Byte add(byte baseValue, byte difference) {
41
-        return null;
46
+        byte easyOne = (byte)(baseValue + difference);
47
+        return easyOne;
42 48
     }
43 49
 
44 50
     /**
@@ -47,7 +53,7 @@ public class MathUtilities {
47 53
      * @return sum of `baseValue` and `difference`
48 54
      */
49 55
     public Float add(float baseValue, float difference) {
50
-        return null;
56
+        return baseValue + difference;
51 57
     }
52 58
 
53 59
     /**
@@ -56,7 +62,7 @@ public class MathUtilities {
56 62
      * @return sum of `baseValue` and `difference`
57 63
      */
58 64
     public Double add(double baseValue, double difference) {
59
-        return null;
65
+        return baseValue + difference;
60 66
     }
61 67
 
62 68
     /**
@@ -65,7 +71,7 @@ public class MathUtilities {
65 71
      * @return difference between `baseValue` and `difference`
66 72
      */
67 73
     public Integer subtract(int baseValue, int difference) {
68
-        return null;
74
+        return baseValue - difference;
69 75
     }
70 76
 
71 77
     /**
@@ -74,7 +80,7 @@ public class MathUtilities {
74 80
      * @return difference between `baseValue` and `difference`
75 81
      */
76 82
     public Long subtract(long baseValue, long difference) {
77
-        return null;
83
+        return baseValue - difference;
78 84
     }
79 85
 
80 86
     /**
@@ -83,7 +89,8 @@ public class MathUtilities {
83 89
      * @return difference between `baseValue` and `difference`
84 90
      */
85 91
     public Short subtract(short baseValue, short difference) {
86
-        return null;
92
+         
93
+        return (short)(baseValue - difference);
87 94
     }
88 95
 
89 96
     /**
@@ -92,7 +99,7 @@ public class MathUtilities {
92 99
      * @return difference between `baseValue` and `difference`
93 100
      */
94 101
     public Byte subtract(byte baseValue, byte difference) {
95
-        return null;
102
+        return (byte)(baseValue - difference);
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 (float)(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 (double)(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,7 @@ 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
+        return (short)(dividend/divisor);
142 149
     }
143 150
 
144 151
     /**
@@ -147,7 +154,7 @@ public class MathUtilities {
147 154
      * @return division of `dividend` by `divisor
148 155
      */
149 156
     public Byte divide(byte dividend, byte divisor) {
150
-        return null;
157
+        return (byte)(dividend/divisor);
151 158
     }
152 159
 
153 160
     /**
@@ -156,7 +163,7 @@ public class MathUtilities {
156 163
      * @return division of `dividend` by `divisor
157 164
      */
158 165
     public Float divide(float dividend, float divisor) {
159
-        return null;
166
+        return dividend/divisor;
160 167
     }
161 168
 
162 169
     /**
@@ -165,7 +172,7 @@ public class MathUtilities {
165 172
      * @return division of `dividend` by `divisor
166 173
      */
167 174
     public Double divide(double dividend, double divisor) {
168
-        return null;
175
+        return (double)(dividend/divisor);
169 176
     }
170 177
 
171 178
 
@@ -175,7 +182,7 @@ public class MathUtilities {
175 182
      * @return product of `multiplicand` by `multiplier`
176 183
      */
177 184
     public Integer multiply(int multiplicand, int multiplier) {
178
-        return null;
185
+        return multiplicand*multiplier;
179 186
     }
180 187
 
181 188
     /**
@@ -184,7 +191,7 @@ public class MathUtilities {
184 191
      * @return product of `multiplicand` by `multiplier`
185 192
      */
186 193
     public Long multiply(long multiplicand, long multiplier) {
187
-        return null;
194
+        return multiplicand*multiplier;
188 195
     }
189 196
 
190 197
     /**
@@ -193,7 +200,7 @@ public class MathUtilities {
193 200
      * @return product of `multiplicand` by `multiplier`
194 201
      */
195 202
     public Short multiply(short multiplicand, short multiplier) {
196
-        return null;
203
+        return (short)(multiplicand*multiplier);
197 204
     }
198 205
     /**
199 206
      * @param multiplicand value to be multiplied
@@ -201,7 +208,7 @@ public class MathUtilities {
201 208
      * @return product of `multiplicand` by `multiplier`
202 209
      */
203 210
     public Byte multiply(byte multiplicand, byte multiplier) {
204
-        return null;
211
+        return (byte)(multiplicand*multiplier);
205 212
     }
206 213
 
207 214
     /**
@@ -210,7 +217,7 @@ public class MathUtilities {
210 217
      * @return product of `multiplicand` by `multiplier`
211 218
      */
212 219
     public Float multiply(float multiplicand, float multiplier) {
213
-        return null;
220
+        return (float)(multiplicand*multiplier);
214 221
     }
215 222
 
216 223
     /**
@@ -219,7 +226,7 @@ public class MathUtilities {
219 226
      * @return product of `multiplicand` by `multiplier`
220 227
      */
221 228
     public Double multiply(double multiplicand, double multiplier) {
222
-        return null;
229
+        return (double)(multiplicand*multiplier);
223 230
     }
224 231
 
225 232
 
@@ -227,14 +234,14 @@ public class MathUtilities {
227 234
       * @return true
228 235
      */
229 236
     public Boolean returnTrue() {
230
-        return null;
237
+        return true;
231 238
     }
232 239
 
233 240
     /**
234 241
      * @return false
235 242
      */
236 243
     public Boolean returnFalse() {
237
-        return null;
244
+        return false;
238 245
     }
239 246
 
240 247
 }

BIN
MathUtilitiesTest.class Ver fichero


+ 2
- 0
MathUtilitiesTest.java Ver fichero

@@ -1,3 +1,5 @@
1
+package DanDoBetterDrills;
2
+
1 3
  
2 4
 
3 5
 import org.junit.Test;

BIN
PredicateUtilities.class Ver fichero


+ 9
- 5
PredicateUtilities.java Ver fichero

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

BIN
PredicateUtilitiesTest.class Ver fichero


+ 2
- 1
PredicateUtilitiesTest.java Ver fichero

@@ -1,3 +1,5 @@
1
+package DanDoBetterDrills;
2
+
1 3
  
2 4
 
3 5
 import org.junit.Test;
@@ -24,7 +26,6 @@ public class PredicateUtilitiesTest {
24 26
         assertTrue(outcome);
25 27
     }
26 28
 
27
-
28 29
     @Test
29 30
     public void testGreaterThanFalse() {
30 31
         // : Given

BIN
StringUtilities.class Ver fichero


+ 20
- 10
StringUtilities.java Ver fichero

@@ -8,7 +8,7 @@ public class StringUtilities {
8 8
      * @return `Hello World` as a string
9 9
      */
10 10
     public static String getHelloWorld() {
11
-        return null;
11
+        return "Hello World";
12 12
     }
13 13
 
14 14
     /**
@@ -17,7 +17,7 @@ public class StringUtilities {
17 17
      * @return the concatenation of two strings, `firstSegment`, and `secondSegment`
18 18
      */
19 19
     public static String concatenation(String firstSegment, String secondSegment){
20
-        return null;
20
+        return firstSegment + secondSegment;
21 21
     }
22 22
 
23 23
     /**
@@ -26,7 +26,8 @@ public class StringUtilities {
26 26
      * @return the concatenation of an integer, `firstSegment`, and a String, `secondSegment`
27 27
      */
28 28
     public static String concatenation(int firstSegment, String secondSegment){
29
-        return null;
29
+        String newSegment = Integer.toString(firstSegment);
30
+        return newSegment + secondSegment;
30 31
     }
31 32
 
32 33
     /**
@@ -34,7 +35,7 @@ public class StringUtilities {
34 35
      * @return the first 3 characters of `input`
35 36
      */
36 37
     public static String getPrefix(String input){
37
-        return null;
38
+        return input.substring(0,3);
38 39
     }
39 40
 
40 41
     /**
@@ -42,7 +43,7 @@ public class StringUtilities {
42 43
      * @return the last 3 characters of `input`
43 44
      */
44 45
     public static String getSuffix(String input){
45
-        return null;
46
+        return input.substring(input.length() - 3);
46 47
     }
47 48
 
48 49
     /**
@@ -51,7 +52,7 @@ public class StringUtilities {
51 52
      * @return the equivalence of two strings, `inputValue` and `comparableValue`
52 53
      */
53 54
     public static Boolean compareTwoStrings(String inputValue, String comparableValue){
54
-        return null;
55
+        return inputValue.equals(comparableValue);
55 56
     }
56 57
 
57 58
     /**
@@ -59,7 +60,11 @@ public class StringUtilities {
59 60
      * @return the middle character of `inputValue`
60 61
      */
61 62
     public static Character getMiddleCharacter(String inputValue){
62
-        return null;
63
+        char newValue;
64
+        if (inputValue.length() % 2 == 0){
65
+        newValue = inputValue.charAt(inputValue.length()/2-1);}
66
+        else { newValue = inputValue.charAt(inputValue.length()/2);}
67
+        return newValue;
63 68
     }
64 69
 
65 70
     /**
@@ -67,7 +72,9 @@ public class StringUtilities {
67 72
      * @return the first sequence of characters
68 73
      */
69 74
     public static String getFirstWord(String spaceDelimitedString){
70
-        return null;
75
+        int i = spaceDelimitedString.indexOf(' ');
76
+        String word = spaceDelimitedString.substring(0, i);
77
+        return word;
71 78
     }
72 79
 
73 80
     /**
@@ -75,7 +82,9 @@ public class StringUtilities {
75 82
      * @return the second word of a string delimited by spaces.
76 83
      */
77 84
     public static String getSecondWord(String spaceDelimitedString){
78
-        return null;
85
+        int i = spaceDelimitedString.indexOf(' ');
86
+        String word = spaceDelimitedString.substring(i + 1, spaceDelimitedString.length());
87
+        return word;
79 88
     }
80 89
 
81 90
     /**
@@ -83,6 +92,7 @@ public class StringUtilities {
83 92
      * @return an identical string with characters in reverse order.
84 93
      */
85 94
     public static String reverse(String stringToReverse){
86
-        return null;
95
+        return new StringBuilder(stringToReverse).reverse().toString();
96
+        
87 97
     }
88 98
 }

+ 10
- 9
package.bluej Ver fichero

@@ -1,23 +1,24 @@
1 1
 #BlueJ package file
2
-editor.fx.0.height=0
3
-editor.fx.0.width=0
4
-editor.fx.0.x=0
5
-editor.fx.0.y=0
2
+dependency1.from=MathUtilitiesTest
3
+dependency1.to=MathUtilities
4
+dependency1.type=UsesDependency
5
+dependency2.from=PredicateUtilitiesTest
6
+dependency2.to=PredicateUtilities
7
+dependency2.type=UsesDependency
6 8
 objectbench.height=129
7
-objectbench.width=1171
9
+objectbench.width=698
8 10
 package.divider.horizontal=0.6
9 11
 package.divider.vertical=0.7490774907749077
10 12
 package.editor.height=399
11 13
 package.editor.width=1069
12
-package.editor.x=59
13
-package.editor.y=63
14
+package.editor.x=120
15
+package.editor.y=60
14 16
 package.frame.height=600
15 17
 package.frame.width=1195
16
-package.numDependencies=0
18
+package.numDependencies=2
17 19
 package.numTargets=6
18 20
 package.showExtends=true
19 21
 package.showUses=true
20
-project.charset=UTF-8
21 22
 readme.height=58
22 23
 readme.name=@README
23 24
 readme.width=47