Browse Source

I have finished the assignment

De'Jon Johnson 6 years ago
parent
commit
e794fd3bad
7 changed files with 112 additions and 48 deletions
  1. BIN
      MathUtilities.class
  2. 50
    26
      MathUtilities.java
  3. BIN
      PredicateUtilities.class
  4. 20
    4
      PredicateUtilities.java
  5. BIN
      StringUtilities.class
  6. 35
    11
      StringUtilities.java
  7. 7
    7
      package.bluej

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 sisterAct = (baseValue + difference);
15
+        return sisterAct;
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 newStuff = (baseValue + difference);
25
+        return newStuff;
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 hello = (short)(baseValue + difference);
35
+        return hello;
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 newStuff = (byte)(baseValue + difference);
45
+        return newStuff;
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 newStuff = (float)(baseValue + difference);
55
+        return newStuff;
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 variableForDouble = (double)(baseValue + difference);
65
+       return variableForDouble;
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 newVar = (int)(baseValue - difference);
75
+        return newVar;
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 sisterAct = (long)(baseValue - difference);
85
+        return sisterAct;
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 newVar = (short)(baseValue - difference);
95
+        return newVar;
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 newVar = (byte)(baseValue - difference);
105
+        return newVar;
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 newVar = (baseValue -difference);
115
+         return newVar;
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 newVar = (baseValue - difference);
125
+        return newVar;
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 newStuff = (short)(dividend/divisor);
156
+        return newStuff;
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 newStuff = (byte) (dividend/divisor);
166
+        return newStuff;
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 newVar = (dividend/divisor);
176
+        return newVar;
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 newVar = (double)(dividend/divisor);
186
+        return newVar;
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 newVar = (multiplicand*multiplier);
197
+        return newVar;
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 newVar = (multiplicand*multiplier);
207
+        return newVar;
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 newVar = (short)(multiplicand*multiplier);
217
+        return newVar;
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 newVar = (byte)(multiplicand*multiplier);
226
+        return newVar;
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 newVar = (multiplicand*multiplier);
236
+        return newVar;
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 newVar = (multiplicand*multiplier);
246
+        return newVar;
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
- 4
PredicateUtilities.java View File

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

BIN
StringUtilities.class View File


+ 35
- 11
StringUtilities.java View File

8
      * @return `Hello World` as a string
8
      * @return `Hello World` as a string
9
      */
9
      */
10
     public static String getHelloWorld() {
10
     public static String getHelloWorld() {
11
-        return null;
11
+        String word = "Hello World";
12
+            return word;
13
+        
12
     }
14
     }
13
 
15
 
14
     /**
16
     /**
17
      * @return the concatenation of two strings, `firstSegment`, and `secondSegment`
19
      * @return the concatenation of two strings, `firstSegment`, and `secondSegment`
18
      */
20
      */
19
     public static String concatenation(String firstSegment, String secondSegment){
21
     public static String concatenation(String firstSegment, String secondSegment){
20
-        return null;
22
+       String word = firstSegment + secondSegment;
23
+       return word;
21
     }
24
     }
22
 
25
 
23
     /**
26
     /**
26
      * @return the concatenation of an integer, `firstSegment`, and a String, `secondSegment`
29
      * @return the concatenation of an integer, `firstSegment`, and a String, `secondSegment`
27
      */
30
      */
28
     public static String concatenation(int firstSegment, String secondSegment){
31
     public static String concatenation(int firstSegment, String secondSegment){
29
-        return null;
32
+        String differentVar = firstSegment + secondSegment;
33
+        return differentVar;
30
     }
34
     }
31
 
35
 
32
     /**
36
     /**
34
      * @return the first 3 characters of `input`
38
      * @return the first 3 characters of `input`
35
      */
39
      */
36
     public static String getPrefix(String input){
40
     public static String getPrefix(String input){
37
-        return null;
41
+      String newString = new String();
42
+      newString = input.substring(0, 3);
43
+      return newString;
38
     }
44
     }
39
 
45
 
40
     /**
46
     /**
42
      * @return the last 3 characters of `input`
48
      * @return the last 3 characters of `input`
43
      */
49
      */
44
     public static String getSuffix(String input){
50
     public static String getSuffix(String input){
45
-        return null;
51
+        String newString = new String();
52
+        newString = input.substring(input.length() - 3);
53
+       return newString;
46
     }
54
     }
47
 
55
 
48
     /**
56
     /**
51
      * @return the equivalence of two strings, `inputValue` and `comparableValue`
59
      * @return the equivalence of two strings, `inputValue` and `comparableValue`
52
      */
60
      */
53
     public static Boolean compareTwoStrings(String inputValue, String comparableValue){
61
     public static Boolean compareTwoStrings(String inputValue, String comparableValue){
54
-        return null;
55
-    }
62
+        if (inputValue.equals(comparableValue)){
63
+            return true;
64
+        } else {
65
+            } return false;
66
+        }
67
+       
68
+   
56
 
69
 
57
     /**
70
     /**
58
      * @param inputValue the value input from user
71
      * @param inputValue the value input from user
59
      * @return the middle character of `inputValue`
72
      * @return the middle character of `inputValue`
60
      */
73
      */
61
     public static Character getMiddleCharacter(String inputValue){
74
     public static Character getMiddleCharacter(String inputValue){
62
-        return null;
75
+        int length =  inputValue.length();
76
+        if (length % 2 == 0){
77
+            return inputValue.charAt((length/2) -1);
78
+    }else{
79
+        return inputValue.charAt((length -1)/2);
63
     }
80
     }
81
+}
64
 
82
 
65
     /**
83
     /**
66
      * @param spaceDelimitedString a string, representative of a sentence, containing spaces
84
      * @param spaceDelimitedString a string, representative of a sentence, containing spaces
67
      * @return the first sequence of characters
85
      * @return the first sequence of characters
68
      */
86
      */
69
     public static String getFirstWord(String spaceDelimitedString){
87
     public static String getFirstWord(String spaceDelimitedString){
70
-        return null;
88
+        String[] dope = spaceDelimitedString.split(" ");
89
+            return dope[0];
90
+        
71
     }
91
     }
72
 
92
 
73
     /**
93
     /**
75
      * @return the second word of a string delimited by spaces.
95
      * @return the second word of a string delimited by spaces.
76
      */
96
      */
77
     public static String getSecondWord(String spaceDelimitedString){
97
     public static String getSecondWord(String spaceDelimitedString){
78
-        return null;
98
+        String[] yerp = spaceDelimitedString.split(" ",3);
99
+        return yerp[1];
79
     }
100
     }
80
 
101
 
81
     /**
102
     /**
83
      * @return an identical string with characters in reverse order.
104
      * @return an identical string with characters in reverse order.
84
      */
105
      */
85
     public static String reverse(String stringToReverse){
106
     public static String reverse(String stringToReverse){
86
-        return null;
107
+       StringBuilder reversedStringNow = new StringBuilder(stringToReverse);
108
+        
109
+        return reversedStringNow.reverse().toString();
110
+       
87
     }
111
     }
88
 }
112
 }

+ 7
- 7
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
6
-objectbench.height=129
2
+editor.fx.0.height=722
3
+editor.fx.0.width=800
4
+editor.fx.0.x=320
5
+editor.fx.0.y=53
6
+objectbench.height=128
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
10
-package.editor.height=399
9
+package.divider.vertical=0.7509225092250923
10
+package.editor.height=400
11
 package.editor.width=1069
11
 package.editor.width=1069
12
 package.editor.x=59
12
 package.editor.x=59
13
 package.editor.y=63
13
 package.editor.y=63