Преглед на файлове

DanDoBetterDrills-completed

Chaitali Patel преди 6 години
родител
ревизия
372df563d1
променени са 7 файла, в които са добавени 129 реда и са изтрити 61 реда
  1. BIN
      MathUtilities.class
  2. 69
    32
      MathUtilities.java
  3. BIN
      PredicateUtilities.class
  4. 16
    5
      PredicateUtilities.java
  5. BIN
      StringUtilities.class
  6. 31
    11
      StringUtilities.java
  7. 13
    13
      package.bluej

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


+ 69
- 32
MathUtilities.java Целия файл

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

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


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

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

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


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

@@ -1,4 +1,3 @@
1
- 
2 1
 
3 2
 /**
4 3
  * Created by dan on 6/14/17.
@@ -8,7 +7,8 @@ public class StringUtilities {
8 7
      * @return `Hello World` as a string
9 8
      */
10 9
     public static String getHelloWorld() {
11
-        return null;
10
+        String greeting="Hello World";
11
+        return greeting;
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 concat=firstSegment+secondSegment;
21
+        return concat;
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 concat=firstSegment+secondSegment;
31
+        return concat;
30 32
     }
31 33
 
32 34
     /**
@@ -34,7 +36,10 @@ 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
+        if(input.length()<=3){
40
+            return input;
41
+        }
42
+        return (input.substring(0,3));
38 43
     }
39 44
 
40 45
     /**
@@ -42,7 +47,8 @@ public class StringUtilities {
42 47
      * @return the last 3 characters of `input`
43 48
      */
44 49
     public static String getSuffix(String input){
45
-        return null;
50
+        String str= input.substring(input.length() - 3);
51
+        return str;
46 52
     }
47 53
 
48 54
     /**
@@ -51,7 +57,8 @@ 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
+        Boolean val= inputValue.equals(comparableValue);
61
+        return val;
55 62
     }
56 63
 
57 64
     /**
@@ -59,15 +66,26 @@ public class StringUtilities {
59 66
      * @return the middle character of `inputValue`
60 67
      */
61 68
     public static Character getMiddleCharacter(String inputValue){
62
-        return null;
69
+        int value=0;
70
+        char middle=0;
71
+        
72
+        if(inputValue.length()%2==0){
73
+        value=(inputValue.length() / 2-1);
74
+        middle= inputValue.charAt(value);
75
+    } else {
76
+        value=(inputValue.length() / 2);
77
+        middle= inputValue.charAt(value);
63 78
     }
79
+    return middle;
80
+}
64 81
 
65 82
     /**
66 83
      * @param spaceDelimitedString a string, representative of a sentence, containing spaces
67 84
      * @return the first sequence of characters
68 85
      */
69 86
     public static String getFirstWord(String spaceDelimitedString){
70
-        return null;
87
+       String arr[] = spaceDelimitedString.split(" ", 2);
88
+       return arr[0];
71 89
     }
72 90
 
73 91
     /**
@@ -75,7 +93,8 @@ public class StringUtilities {
75 93
      * @return the second word of a string delimited by spaces.
76 94
      */
77 95
     public static String getSecondWord(String spaceDelimitedString){
78
-        return null;
96
+       String arr[] = spaceDelimitedString.split(" ", 2);
97
+       return arr[1];
79 98
     }
80 99
 
81 100
     /**
@@ -83,6 +102,7 @@ public class StringUtilities {
83 102
      * @return an identical string with characters in reverse order.
84 103
      */
85 104
     public static String reverse(String stringToReverse){
86
-        return null;
105
+        StringBuilder sb =new StringBuilder(stringToReverse);
106
+        return sb.reverse().toString();
87 107
     }
88 108
 }

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

@@ -1,18 +1,18 @@
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
7
-objectbench.width=1171
2
+editor.fx.0.height=722
3
+editor.fx.0.width=800
4
+editor.fx.0.x=434
5
+editor.fx.0.y=23
6
+objectbench.height=128
7
+objectbench.width=835
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.7518382352941176
10
+package.editor.height=402
11
+package.editor.width=733
12
+package.editor.x=194
13
+package.editor.y=82
14
+package.frame.height=602
15
+package.frame.width=859
16 16
 package.numDependencies=0
17 17
 package.numTargets=6
18 18
 package.showExtends=true