Demetrius Murray преди 6 години
родител
ревизия
4a59724f84
променени са 10 файла, в които са добавени 142 реда и са изтрити 54 реда
  1. BIN
      MathUtilities.class
  2. 50
    26
      MathUtilities.java
  3. BIN
      PredicateUtilities.class
  4. 20
    5
      PredicateUtilities.java
  5. BIN
      StringUtilities.class
  6. 33
    11
      StringUtilities.java
  7. BIN
      ZipcodeRocks.class
  8. 6
    0
      ZipcodeRocks.ctxt
  9. 14
    0
      ZipcodeRocks.java
  10. 19
    12
      package.bluej

BIN
MathUtilities.class Целия файл


+ 50
- 26
MathUtilities.java Целия файл

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

BIN
PredicateUtilities.class Целия файл


+ 20
- 5
PredicateUtilities.java Целия файл

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

BIN
StringUtilities.class Целия файл


+ 33
- 11
StringUtilities.java Целия файл

@@ -1,4 +1,3 @@
1
- 
2 1
 
3 2
 /**
4 3
  * Created by dan on 6/14/17.
@@ -8,7 +7,7 @@ public class StringUtilities {
8 7
      * @return `Hello World` as a string
9 8
      */
10 9
     public static String getHelloWorld() {
11
-        return null;
10
+        return "Hello Word";
12 11
     }
13 12
 
14 13
     /**
@@ -17,7 +16,7 @@ public class StringUtilities {
17 16
      * @return the concatenation of two strings, `firstSegment`, and `secondSegment`
18 17
      */
19 18
     public static String concatenation(String firstSegment, String secondSegment){
20
-        return null;
19
+        return firstSegment + secondSegment;
21 20
     }
22 21
 
23 22
     /**
@@ -26,7 +25,7 @@ public class StringUtilities {
26 25
      * @return the concatenation of an integer, `firstSegment`, and a String, `secondSegment`
27 26
      */
28 27
     public static String concatenation(int firstSegment, String secondSegment){
29
-        return null;
28
+        return firstSegment+secondSegment;
30 29
     }
31 30
 
32 31
     /**
@@ -34,7 +33,7 @@ public class StringUtilities {
34 33
      * @return the first 3 characters of `input`
35 34
      */
36 35
     public static String getPrefix(String input){
37
-        return null;
36
+        return input.substring(3);
38 37
     }
39 38
 
40 39
     /**
@@ -42,7 +41,7 @@ public class StringUtilities {
42 41
      * @return the last 3 characters of `input`
43 42
      */
44 43
     public static String getSuffix(String input){
45
-        return null;
44
+        return input.substring(input.length()-4);
46 45
     }
47 46
 
48 47
     /**
@@ -51,7 +50,9 @@ public class StringUtilities {
51 50
      * @return the equivalence of two strings, `inputValue` and `comparableValue`
52 51
      */
53 52
     public static Boolean compareTwoStrings(String inputValue, String comparableValue){
54
-        return null;
53
+        boolean result;
54
+        result = inputValue == comparableValue ? true : false;
55
+        return result;
55 56
     }
56 57
 
57 58
     /**
@@ -59,7 +60,15 @@ 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
+        int midpoint;
64
+
65
+        if(inputValue.length()%2!=0){
66
+            midpoint = (inputValue.length()-1)/2;
67
+        } else {
68
+            midpoint = (inputValue.length()/2)-1;
69
+        }
70
+
71
+        return inputValue.charAt(midpoint);
63 72
     }
64 73
 
65 74
     /**
@@ -67,7 +76,9 @@ public class StringUtilities {
67 76
      * @return the first sequence of characters
68 77
      */
69 78
     public static String getFirstWord(String spaceDelimitedString){
70
-        return null;
79
+        String word = spaceDelimitedString;
80
+        int delim = word.indexOf(' ');
81
+        return word.substring(0,delim);
71 82
     }
72 83
 
73 84
     /**
@@ -75,7 +86,9 @@ public class StringUtilities {
75 86
      * @return the second word of a string delimited by spaces.
76 87
      */
77 88
     public static String getSecondWord(String spaceDelimitedString){
78
-        return null;
89
+        String word = spaceDelimitedString;
90
+        int delim = word.indexOf(' ');
91
+        return word.substring(delim+1);
79 92
     }
80 93
 
81 94
     /**
@@ -83,6 +96,15 @@ public class StringUtilities {
83 96
      * @return an identical string with characters in reverse order.
84 97
      */
85 98
     public static String reverse(String stringToReverse){
86
-        return null;
99
+        StringBuilder builder = new StringBuilder();
100
+        String word = stringToReverse;
101
+  
102
+        for (int i = word.length()-1; i>=0; i--){
103
+            builder.append(word.charAt(i));
104
+        }
105
+        
106
+        String result = builder.toString();
107
+        System.out.println(result);
108
+        return result;
87 109
     }
88 110
 }

BIN
ZipcodeRocks.class Целия файл


+ 6
- 0
ZipcodeRocks.ctxt Целия файл

@@ -0,0 +1,6 @@
1
+#BlueJ class context
2
+comment0.target=ZipcodeRocks
3
+comment0.text=\n\ Write\ a\ description\ of\ class\ ZipcodeRocks\ here.\n\n\ @author\ (your\ name)\n\ @version\ (a\ version\ number\ or\ a\ date)\n
4
+comment1.params=args
5
+comment1.target=void\ main(java.lang.String[])
6
+numComments=2

+ 14
- 0
ZipcodeRocks.java Целия файл

@@ -0,0 +1,14 @@
1
+    
2
+    /**
3
+     * Write a description of class ZipcodeRocks here.
4
+     *
5
+     * @author (your name)
6
+     * @version (a version number or a date)
7
+     */
8
+    public class ZipcodeRocks
9
+    {
10
+    public static void main(String[] args){
11
+        System.out.println("Zipcode Rocks!");
12
+    }
13
+    
14
+}

+ 19
- 12
package.bluej Целия файл

@@ -1,20 +1,20 @@
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
+editor.fx.0.height=717
3
+editor.fx.0.width=800
4
+editor.fx.0.x=-270
5
+editor.fx.0.y=-823
6 6
 objectbench.height=129
7 7
 objectbench.width=1171
8 8
 package.divider.horizontal=0.6
9 9
 package.divider.vertical=0.7490774907749077
10 10
 package.editor.height=399
11 11
 package.editor.width=1069
12
-package.editor.x=59
13
-package.editor.y=63
12
+package.editor.x=367
13
+package.editor.y=-709
14 14
 package.frame.height=600
15 15
 package.frame.width=1195
16 16
 package.numDependencies=0
17
-package.numTargets=6
17
+package.numTargets=7
18 18
 package.showExtends=true
19 19
 package.showUses=true
20 20
 project.charset=UTF-8
@@ -59,9 +59,16 @@ target5.width=160
59 59
 target5.x=260
60 60
 target5.y=50
61 61
 target6.height=50
62
-target6.name=MathUtilitiesTest
62
+target6.name=ZipcodeRocks
63 63
 target6.showInterface=false
64
-target6.type=UnitTestTargetJunit4
65
-target6.width=130
66
-target6.x=50
67
-target6.y=90
64
+target6.type=ClassTarget
65
+target6.width=110
66
+target6.x=70
67
+target6.y=10
68
+target7.height=50
69
+target7.name=MathUtilitiesTest
70
+target7.showInterface=false
71
+target7.type=UnitTestTargetJunit4
72
+target7.width=130
73
+target7.x=50
74
+target7.y=90