Browse Source

Completed

Demetrius Murray 6 years ago
parent
commit
4a59724f84

BIN
MathUtilities.class View File


+ 50
- 26
MathUtilities.java View File

11
      * @return sum of `baseValue` and `difference`
11
      * @return sum of `baseValue` and `difference`
12
      */
12
      */
13
     public Integer add(int baseValue, int difference) {
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
      * @return sum of `baseValue` and `difference`
21
      * @return sum of `baseValue` and `difference`
21
      */
22
      */
22
     public Long add(long baseValue, long difference) {
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
      * @return sum of `baseValue` and `difference`
31
      * @return sum of `baseValue` and `difference`
30
      */
32
      */
31
     public Short add(short baseValue, short difference) {
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
      * @return sum of `baseValue` and `difference`
41
      * @return sum of `baseValue` and `difference`
39
      */
42
      */
40
     public Byte add(byte baseValue, byte difference) {
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
      * @return sum of `baseValue` and `difference`
51
      * @return sum of `baseValue` and `difference`
48
      */
52
      */
49
     public Float add(float baseValue, float difference) {
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
      * @return sum of `baseValue` and `difference`
61
      * @return sum of `baseValue` and `difference`
57
      */
62
      */
58
     public Double add(double baseValue, double difference) {
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
      * @return difference between `baseValue` and `difference`
71
      * @return difference between `baseValue` and `difference`
66
      */
72
      */
67
     public Integer subtract(int baseValue, int difference) {
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
      * @return difference between `baseValue` and `difference`
81
      * @return difference between `baseValue` and `difference`
75
      */
82
      */
76
     public Long subtract(long baseValue, long difference) {
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
      * @return difference between `baseValue` and `difference`
91
      * @return difference between `baseValue` and `difference`
84
      */
92
      */
85
     public Short subtract(short baseValue, short difference) {
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
      * @return difference between `baseValue` and `difference`
101
      * @return difference between `baseValue` and `difference`
93
      */
102
      */
94
     public Byte subtract(byte baseValue, byte difference) {
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
      * @return difference between `baseValue` and `difference`
111
      * @return difference between `baseValue` and `difference`
102
      */
112
      */
103
     public Float subtract(float baseValue, float difference) {
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
      * @return difference between `baseValue` and `difference`
121
      * @return difference between `baseValue` and `difference`
111
      */
122
      */
112
     public Double subtract(double baseValue, double difference) {
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
      * @return division of `dividend` by `divisor
132
      * @return division of `dividend` by `divisor
121
      */
133
      */
122
     public Integer divide(int dividend, int divisor) {
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
      * @return division of `dividend` by `divisor
142
      * @return division of `dividend` by `divisor
130
      */
143
      */
131
     public Long divide(long dividend, long divisor) {
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
      * @return division of `dividend` by `divisor
152
      * @return division of `dividend` by `divisor
139
      */
153
      */
140
     public Short divide(short dividend, short divisor) {
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
      * @return division of `dividend` by `divisor
162
      * @return division of `dividend` by `divisor
148
      */
163
      */
149
     public Byte divide(byte dividend, byte divisor) {
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
      * @return division of `dividend` by `divisor
172
      * @return division of `dividend` by `divisor
157
      */
173
      */
158
     public Float divide(float dividend, float divisor) {
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
      * @return division of `dividend` by `divisor
182
      * @return division of `dividend` by `divisor
166
      */
183
      */
167
     public Double divide(double dividend, double divisor) {
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
      * @return product of `multiplicand` by `multiplier`
193
      * @return product of `multiplicand` by `multiplier`
176
      */
194
      */
177
     public Integer multiply(int multiplicand, int multiplier) {
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
      * @return product of `multiplicand` by `multiplier`
203
      * @return product of `multiplicand` by `multiplier`
185
      */
204
      */
186
     public Long multiply(long multiplicand, long multiplier) {
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
      * @return product of `multiplicand` by `multiplier`
213
      * @return product of `multiplicand` by `multiplier`
194
      */
214
      */
195
     public Short multiply(short multiplicand, short multiplier) {
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
      * @param multiplicand value to be multiplied
220
      * @param multiplicand value to be multiplied
201
      * @return product of `multiplicand` by `multiplier`
222
      * @return product of `multiplicand` by `multiplier`
202
      */
223
      */
203
     public Byte multiply(byte multiplicand, byte multiplier) {
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
      * @return product of `multiplicand` by `multiplier`
232
      * @return product of `multiplicand` by `multiplier`
211
      */
233
      */
212
     public Float multiply(float multiplicand, float multiplier) {
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
      * @return product of `multiplicand` by `multiplier`
242
      * @return product of `multiplicand` by `multiplier`
220
      */
243
      */
221
     public Double multiply(double multiplicand, double multiplier) {
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
       * @return true
251
       * @return true
228
      */
252
      */
229
     public Boolean returnTrue() {
253
     public Boolean returnTrue() {
230
-        return null;
254
+        return true;
231
     }
255
     }
232
 
256
 
233
     /**
257
     /**
234
      * @return false
258
      * @return false
235
      */
259
      */
236
     public Boolean returnFalse() {
260
     public Boolean returnFalse() {
237
-        return null;
261
+        return false;
238
     }
262
     }
239
 
263
 
240
 }
264
 }

BIN
PredicateUtilities.class View File


+ 20
- 5
PredicateUtilities.java View File

1
- 
2
 
1
 
3
 /**
2
 /**
4
  * Created by dan on 6/14/17.
3
  * Created by dan on 6/14/17.
10
      * @return true if `x` is greater than `y`
9
      * @return true if `x` is greater than `y`
11
      */
10
      */
12
     public Boolean isGreaterThan(int x, int y) {
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
      * @return true if `x` is less than `y`
22
      * @return true if `x` is less than `y`
20
      */
23
      */
21
     public Boolean isLessThan(int x, int y) {
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
      * @return true if `x` is greater than or equal to `y`
35
      * @return true if `x` is greater than or equal to `y`
29
      */
36
      */
30
     public Boolean isGreaterThanOrEqualTo(int x, int y) {
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
      * @return true if `x` is less than or equal to `y`
48
      * @return true if `x` is less than or equal to `y`
38
      */
49
      */
39
     public Boolean isLessThanOrEqualTo(int x, int y) {
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 View File


+ 33
- 11
StringUtilities.java View File

1
- 
2
 
1
 
3
 /**
2
 /**
4
  * Created by dan on 6/14/17.
3
  * Created by dan on 6/14/17.
8
      * @return `Hello World` as a string
7
      * @return `Hello World` as a string
9
      */
8
      */
10
     public static String getHelloWorld() {
9
     public static String getHelloWorld() {
11
-        return null;
10
+        return "Hello Word";
12
     }
11
     }
13
 
12
 
14
     /**
13
     /**
17
      * @return the concatenation of two strings, `firstSegment`, and `secondSegment`
16
      * @return the concatenation of two strings, `firstSegment`, and `secondSegment`
18
      */
17
      */
19
     public static String concatenation(String firstSegment, String secondSegment){
18
     public static String concatenation(String firstSegment, String secondSegment){
20
-        return null;
19
+        return firstSegment + secondSegment;
21
     }
20
     }
22
 
21
 
23
     /**
22
     /**
26
      * @return the concatenation of an integer, `firstSegment`, and a String, `secondSegment`
25
      * @return the concatenation of an integer, `firstSegment`, and a String, `secondSegment`
27
      */
26
      */
28
     public static String concatenation(int firstSegment, String secondSegment){
27
     public static String concatenation(int firstSegment, String secondSegment){
29
-        return null;
28
+        return firstSegment+secondSegment;
30
     }
29
     }
31
 
30
 
32
     /**
31
     /**
34
      * @return the first 3 characters of `input`
33
      * @return the first 3 characters of `input`
35
      */
34
      */
36
     public static String getPrefix(String input){
35
     public static String getPrefix(String input){
37
-        return null;
36
+        return input.substring(3);
38
     }
37
     }
39
 
38
 
40
     /**
39
     /**
42
      * @return the last 3 characters of `input`
41
      * @return the last 3 characters of `input`
43
      */
42
      */
44
     public static String getSuffix(String input){
43
     public static String getSuffix(String input){
45
-        return null;
44
+        return input.substring(input.length()-4);
46
     }
45
     }
47
 
46
 
48
     /**
47
     /**
51
      * @return the equivalence of two strings, `inputValue` and `comparableValue`
50
      * @return the equivalence of two strings, `inputValue` and `comparableValue`
52
      */
51
      */
53
     public static Boolean compareTwoStrings(String inputValue, String comparableValue){
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
      * @return the middle character of `inputValue`
60
      * @return the middle character of `inputValue`
60
      */
61
      */
61
     public static Character getMiddleCharacter(String inputValue){
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
      * @return the first sequence of characters
76
      * @return the first sequence of characters
68
      */
77
      */
69
     public static String getFirstWord(String spaceDelimitedString){
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
      * @return the second word of a string delimited by spaces.
86
      * @return the second word of a string delimited by spaces.
76
      */
87
      */
77
     public static String getSecondWord(String spaceDelimitedString){
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
      * @return an identical string with characters in reverse order.
96
      * @return an identical string with characters in reverse order.
84
      */
97
      */
85
     public static String reverse(String stringToReverse){
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 View File


+ 6
- 0
ZipcodeRocks.ctxt View File

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 View File

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 View File

1
 #BlueJ package file
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
 objectbench.height=129
6
 objectbench.height=129
7
 objectbench.width=1171
7
 objectbench.width=1171
8
 package.divider.horizontal=0.6
8
 package.divider.horizontal=0.6
9
 package.divider.vertical=0.7490774907749077
9
 package.divider.vertical=0.7490774907749077
10
 package.editor.height=399
10
 package.editor.height=399
11
 package.editor.width=1069
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
 package.frame.height=600
14
 package.frame.height=600
15
 package.frame.width=1195
15
 package.frame.width=1195
16
 package.numDependencies=0
16
 package.numDependencies=0
17
-package.numTargets=6
17
+package.numTargets=7
18
 package.showExtends=true
18
 package.showExtends=true
19
 package.showUses=true
19
 package.showUses=true
20
 project.charset=UTF-8
20
 project.charset=UTF-8
59
 target5.x=260
59
 target5.x=260
60
 target5.y=50
60
 target5.y=50
61
 target6.height=50
61
 target6.height=50
62
-target6.name=MathUtilitiesTest
62
+target6.name=ZipcodeRocks
63
 target6.showInterface=false
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