瀏覽代碼

I have finished the assignment

De'Jon Johnson 6 年之前
父節點
當前提交
e794fd3bad
共有 7 個檔案被更改,包括 112 行新增48 行删除
  1. 二進制
      MathUtilities.class
  2. 50
    26
      MathUtilities.java
  3. 二進制
      PredicateUtilities.class
  4. 20
    4
      PredicateUtilities.java
  5. 二進制
      StringUtilities.class
  6. 35
    11
      StringUtilities.java
  7. 7
    7
      package.bluej

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

二進制
PredicateUtilities.class 查看文件


+ 20
- 4
PredicateUtilities.java 查看文件

@@ -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
+        return true;
15
+    } else{
16
+        return false;
17
+    }
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
+        return true;
28
+    } else {
29
+        return false;
30
+    }
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
+        return true;
41
+    } else {
42
+        return false;
43
+    }
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
+        return true;
54
+    } else {
55
+        return false;
41 56
     }
57
+}
42 58
 }

二進制
StringUtilities.class 查看文件


+ 35
- 11
StringUtilities.java 查看文件

@@ -8,7 +8,9 @@ public class StringUtilities {
8 8
      * @return `Hello World` as a string
9 9
      */
10 10
     public static String getHelloWorld() {
11
-        return null;
11
+        String word = "Hello World";
12
+            return word;
13
+        
12 14
     }
13 15
 
14 16
     /**
@@ -17,7 +19,8 @@ public class StringUtilities {
17 19
      * @return the concatenation of two strings, `firstSegment`, and `secondSegment`
18 20
      */
19 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,7 +29,8 @@ public class StringUtilities {
26 29
      * @return the concatenation of an integer, `firstSegment`, and a String, `secondSegment`
27 30
      */
28 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,7 +38,9 @@ public class StringUtilities {
34 38
      * @return the first 3 characters of `input`
35 39
      */
36 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,7 +48,9 @@ public class StringUtilities {
42 48
      * @return the last 3 characters of `input`
43 49
      */
44 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,23 +59,35 @@ public class StringUtilities {
51 59
      * @return the equivalence of two strings, `inputValue` and `comparableValue`
52 60
      */
53 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 71
      * @param inputValue the value input from user
59 72
      * @return the middle character of `inputValue`
60 73
      */
61 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 84
      * @param spaceDelimitedString a string, representative of a sentence, containing spaces
67 85
      * @return the first sequence of characters
68 86
      */
69 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,7 +95,8 @@ public class StringUtilities {
75 95
      * @return the second word of a string delimited by spaces.
76 96
      */
77 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,6 +104,9 @@ public class StringUtilities {
83 104
      * @return an identical string with characters in reverse order.
84 105
      */
85 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 查看文件

@@ -1,13 +1,13 @@
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
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 7
 objectbench.width=1171
8 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 11
 package.editor.width=1069
12 12
 package.editor.x=59
13 13
 package.editor.y=63