Jose Bedolla vor 6 Jahren
Ursprung
Commit
799141dad7
7 geänderte Dateien mit 130 neuen und 51 gelöschten Zeilen
  1. BIN
      MathUtilities.class
  2. 70
    26
      MathUtilities.java
  3. BIN
      PredicateUtilities.class
  4. 20
    4
      PredicateUtilities.java
  5. BIN
      StringUtilities.class
  6. 28
    10
      StringUtilities.java
  7. 12
    11
      package.bluej

BIN
MathUtilities.class Datei anzeigen


+ 70
- 26
MathUtilities.java Datei anzeigen

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

BIN
PredicateUtilities.class Datei anzeigen


+ 20
- 4
PredicateUtilities.java Datei anzeigen

@@ -10,7 +10,11 @@ public class PredicateUtilities {
10 10
      * @return true if `x` is greater than `y`
11 11
      */
12 12
     public Boolean isGreaterThan(int x, int y) {
13
-        return null;
13
+        if(x>y)
14
+        {
15
+        return true;
16
+        }
17
+        return false;
14 18
     }
15 19
 
16 20
     /**
@@ -19,7 +23,11 @@ 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
+        if(x<y)
27
+        {
28
+        return true;
29
+        }
30
+        return false;
23 31
     }
24 32
 
25 33
     /**
@@ -28,7 +36,11 @@ public class PredicateUtilities {
28 36
      * @return true if `x` is greater than or equal to `y`
29 37
      */
30 38
     public Boolean isGreaterThanOrEqualTo(int x, int y) {
31
-        return null;
39
+        if(x >= y)
40
+        {
41
+            return true;
42
+        }
43
+        return false;
32 44
     }
33 45
 
34 46
     /**
@@ -37,6 +49,10 @@ public class PredicateUtilities {
37 49
      * @return true if `x` is less than or equal to `y`
38 50
      */
39 51
     public Boolean isLessThanOrEqualTo(int x, int y) {
40
-        return null;
52
+        if(x <= y)
53
+        {
54
+            return true;
55
+        }
56
+        return false;
41 57
     }
42 58
 }

BIN
StringUtilities.class Datei anzeigen


+ 28
- 10
StringUtilities.java Datei anzeigen

@@ -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,8 @@ 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
+        String together = firstSegment + secondSegment;//String.format(firstSegment,secondSegment);
21
+        return together;
21 22
     }
22 23
 
23 24
     /**
@@ -26,7 +27,8 @@ public class StringUtilities {
26 27
      * @return the concatenation of an integer, `firstSegment`, and a String, `secondSegment`
27 28
      */
28 29
     public static String concatenation(int firstSegment, String secondSegment){
29
-        return null;
30
+        String together = firstSegment + secondSegment;
31
+        return together;
30 32
     }
31 33
 
32 34
     /**
@@ -34,7 +36,8 @@ public class StringUtilities {
34 36
      * @return the first 3 characters of `input`
35 37
      */
36 38
     public static String getPrefix(String input){
37
-        return null;
39
+       
40
+        return input.substring(0,3);
38 41
     }
39 42
 
40 43
     /**
@@ -42,7 +45,10 @@ public class StringUtilities {
42 45
      * @return the last 3 characters of `input`
43 46
      */
44 47
     public static String getSuffix(String input){
45
-        return null;
48
+        
49
+        int lenght = input.length();
50
+        String n = input.substring(input.length() -3);
51
+        return n;
46 52
     }
47 53
 
48 54
     /**
@@ -51,7 +57,11 @@ public class StringUtilities {
51 57
      * @return the equivalence of two strings, `inputValue` and `comparableValue`
52 58
      */
53 59
     public static Boolean compareTwoStrings(String inputValue, String comparableValue){
54
-        return null;
60
+        if(inputValue == comparableValue)
61
+        {
62
+         return true;
63
+        }
64
+        return false;
55 65
     }
56 66
 
57 67
     /**
@@ -59,7 +69,10 @@ public class StringUtilities {
59 69
      * @return the middle character of `inputValue`
60 70
      */
61 71
     public static Character getMiddleCharacter(String inputValue){
62
-        return null;
72
+        int i = inputValue.length();
73
+        int middleC = i/2;
74
+        char c = inputValue.charAt(middleC);
75
+        return c;
63 76
     }
64 77
 
65 78
     /**
@@ -67,7 +80,8 @@ public class StringUtilities {
67 80
      * @return the first sequence of characters
68 81
      */
69 82
     public static String getFirstWord(String spaceDelimitedString){
70
-        return null;
83
+        String s[] = spaceDelimitedString.split(" ");
84
+        return s[0];
71 85
     }
72 86
 
73 87
     /**
@@ -75,7 +89,10 @@ public class StringUtilities {
75 89
      * @return the second word of a string delimited by spaces.
76 90
      */
77 91
     public static String getSecondWord(String spaceDelimitedString){
78
-        return null;
92
+
93
+       String s[] = spaceDelimitedString.split(" ");
94
+
95
+       return s[1];
79 96
     }
80 97
 
81 98
     /**
@@ -83,6 +100,7 @@ public class StringUtilities {
83 100
      * @return an identical string with characters in reverse order.
84 101
      */
85 102
     public static String reverse(String stringToReverse){
86
-        return null;
103
+     StringBuilder reversing = new StringBuilder(stringToReverse);
104
+     return reversing.reverse().toString();
87 105
     }
88 106
 }

+ 12
- 11
package.bluej Datei anzeigen

@@ -4,15 +4,15 @@ editor.fx.0.width=0
4 4
 editor.fx.0.x=0
5 5
 editor.fx.0.y=0
6 6
 objectbench.height=129
7
-objectbench.width=1171
7
+objectbench.width=622
8 8
 package.divider.horizontal=0.6
9
-package.divider.vertical=0.7490774907749077
10
-package.editor.height=399
11
-package.editor.width=1069
12
-package.editor.x=59
13
-package.editor.y=63
14
-package.frame.height=600
15
-package.frame.width=1195
9
+package.divider.vertical=0.7567084078711985
10
+package.editor.height=400
11
+package.editor.width=520
12
+package.editor.x=2270
13
+package.editor.y=59
14
+package.frame.height=617
15
+package.frame.width=646
16 16
 package.numDependencies=0
17 17
 package.numTargets=6
18 18
 package.showExtends=true
@@ -37,6 +37,7 @@ target2.type=UnitTestTargetJunit4
37 37
 target2.width=140
38 38
 target2.x=490
39 39
 target2.y=70
40
+target3.association=MathUtilitiesTest
40 41
 target3.height=50
41 42
 target3.name=MathUtilities
42 43
 target3.showInterface=false
@@ -62,6 +63,6 @@ target6.height=50
62 63
 target6.name=MathUtilitiesTest
63 64
 target6.showInterface=false
64 65
 target6.type=UnitTestTargetJunit4
65
-target6.width=130
66
-target6.x=50
67
-target6.y=90
66
+target6.width=100
67
+target6.x=90
68
+target6.y=120