Kaynağa Gözat

while loops

Nuridalia Hermandez 6 yıl önce
ebeveyn
işleme
7e65187aa1

BIN
MathUtilities.class Dosyayı Görüntüle


+ 14
- 13
MathUtilities.java Dosyayı Görüntüle

@@ -11,7 +11,7 @@ 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
+        return baseValue + difference;
15 15
     }
16 16
 
17 17
     /**
@@ -20,7 +20,7 @@ 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
+        return baseValue + difference;
24 24
     }
25 25
 
26 26
     /**
@@ -38,6 +38,7 @@ public class MathUtilities {
38 38
      * @return sum of `baseValue` and `difference`
39 39
      */
40 40
     public Byte add(byte baseValue, byte difference) {
41
+        
41 42
         return null;
42 43
     }
43 44
 
@@ -56,7 +57,7 @@ public class MathUtilities {
56 57
      * @return sum of `baseValue` and `difference`
57 58
      */
58 59
     public Double add(double baseValue, double difference) {
59
-        return null;
60
+        return baseValue + difference;
60 61
     }
61 62
 
62 63
     /**
@@ -65,7 +66,7 @@ public class MathUtilities {
65 66
      * @return difference between `baseValue` and `difference`
66 67
      */
67 68
     public Integer subtract(int baseValue, int difference) {
68
-        return null;
69
+        return baseValue - difference;
69 70
     }
70 71
 
71 72
     /**
@@ -110,7 +111,7 @@ public class MathUtilities {
110 111
      * @return difference between `baseValue` and `difference`
111 112
      */
112 113
     public Double subtract(double baseValue, double difference) {
113
-        return null;
114
+        return baseValue - difference;
114 115
     }
115 116
 
116 117
 
@@ -120,7 +121,7 @@ public class MathUtilities {
120 121
      * @return division of `dividend` by `divisor
121 122
      */
122 123
     public Integer divide(int dividend, int divisor) {
123
-        return null;
124
+        return dividend/divisor;
124 125
     }
125 126
 
126 127
     /**
@@ -129,7 +130,7 @@ public class MathUtilities {
129 130
      * @return division of `dividend` by `divisor
130 131
      */
131 132
     public Long divide(long dividend, long divisor) {
132
-        return null;
133
+        return dividend/divisor;
133 134
     }
134 135
 
135 136
     /**
@@ -156,7 +157,7 @@ public class MathUtilities {
156 157
      * @return division of `dividend` by `divisor
157 158
      */
158 159
     public Float divide(float dividend, float divisor) {
159
-        return null;
160
+        return dividend/ divisor;
160 161
     }
161 162
 
162 163
     /**
@@ -165,7 +166,7 @@ public class MathUtilities {
165 166
      * @return division of `dividend` by `divisor
166 167
      */
167 168
     public Double divide(double dividend, double divisor) {
168
-        return null;
169
+        return dividend/divisor;
169 170
     }
170 171
 
171 172
 
@@ -175,7 +176,7 @@ public class MathUtilities {
175 176
      * @return product of `multiplicand` by `multiplier`
176 177
      */
177 178
     public Integer multiply(int multiplicand, int multiplier) {
178
-        return null;
179
+        return multiplicand*multiplier;
179 180
     }
180 181
 
181 182
     /**
@@ -219,7 +220,7 @@ public class MathUtilities {
219 220
      * @return product of `multiplicand` by `multiplier`
220 221
      */
221 222
     public Double multiply(double multiplicand, double multiplier) {
222
-        return null;
223
+        return multiplicand * multiplier ;
223 224
     }
224 225
 
225 226
 
@@ -227,14 +228,14 @@ public class MathUtilities {
227 228
       * @return true
228 229
      */
229 230
     public Boolean returnTrue() {
230
-        return null;
231
+        return true;
231 232
     }
232 233
 
233 234
     /**
234 235
      * @return false
235 236
      */
236 237
     public Boolean returnFalse() {
237
-        return null;
238
+        return false;
238 239
     }
239 240
 
240 241
 }

BIN
PredicateUtilities.class Dosyayı Görüntüle


+ 4
- 4
PredicateUtilities.java Dosyayı Görüntüle

@@ -10,7 +10,7 @@ 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
+        return x>y;
14 14
     }
15 15
 
16 16
     /**
@@ -19,7 +19,7 @@ public class PredicateUtilities {
19 19
      * @return true if `x` is less than `y`
20 20
      */
21 21
     public Boolean isLessThan(int x, int y) {
22
-        return null;
22
+        return x<y;
23 23
     }
24 24
 
25 25
     /**
@@ -28,7 +28,7 @@ public class PredicateUtilities {
28 28
      * @return true if `x` is greater than or equal to `y`
29 29
      */
30 30
     public Boolean isGreaterThanOrEqualTo(int x, int y) {
31
-        return null;
31
+        return x>=y;
32 32
     }
33 33
 
34 34
     /**
@@ -37,6 +37,6 @@ public class PredicateUtilities {
37 37
      * @return true if `x` is less than or equal to `y`
38 38
      */
39 39
     public Boolean isLessThanOrEqualTo(int x, int y) {
40
-        return null;
40
+        return x<=y;
41 41
     }
42 42
 }

BIN
StringUtilities.class Dosyayı Görüntüle


+ 12
- 8
StringUtilities.java Dosyayı Görüntüle

@@ -8,7 +8,7 @@ public class StringUtilities {
8 8
      * @return `Hello World` as a string
9 9
      */
10 10
     public static String getHelloWorld() {
11
-        return null;
11
+        return "Hello World";
12 12
     }
13 13
 
14 14
     /**
@@ -17,7 +17,7 @@ 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
+        return firstSegment + secondSegment ;
21 21
     }
22 22
 
23 23
     /**
@@ -26,7 +26,10 @@ public class StringUtilities {
26 26
      * @return the concatenation of an integer, `firstSegment`, and a String, `secondSegment`
27 27
      */
28 28
     public static String concatenation(int firstSegment, String secondSegment){
29
-        return null;
29
+        String n = Integer.toString(firstSegment);
30
+        return n + secondSegment;
31
+        
32
+        
30 33
     }
31 34
 
32 35
     /**
@@ -34,7 +37,7 @@ public class StringUtilities {
34 37
      * @return the first 3 characters of `input`
35 38
      */
36 39
     public static String getPrefix(String input){
37
-        return null;
40
+        return input.substring(0, 3);
38 41
     }
39 42
 
40 43
     /**
@@ -42,7 +45,7 @@ public class StringUtilities {
42 45
      * @return the last 3 characters of `input`
43 46
      */
44 47
     public static String getSuffix(String input){
45
-        return null;
48
+        return input.substring(input.length() - 3);
46 49
     }
47 50
 
48 51
     /**
@@ -51,7 +54,7 @@ public class StringUtilities {
51 54
      * @return the equivalence of two strings, `inputValue` and `comparableValue`
52 55
      */
53 56
     public static Boolean compareTwoStrings(String inputValue, String comparableValue){
54
-        return null;
57
+        return inputValue.equals(comparableValue) ;
55 58
     }
56 59
 
57 60
     /**
@@ -59,7 +62,7 @@ public class StringUtilities {
59 62
      * @return the middle character of `inputValue`
60 63
      */
61 64
     public static Character getMiddleCharacter(String inputValue){
62
-        return null;
65
+        return inputValue.charAt(inputValue.length()/2);
63 66
     }
64 67
 
65 68
     /**
@@ -67,7 +70,8 @@ public class StringUtilities {
67 70
      * @return the first sequence of characters
68 71
      */
69 72
     public static String getFirstWord(String spaceDelimitedString){
70
-        return null;
73
+        String str= spaceDelimitedString.split(" ");
74
+        return  ;
71 75
     }
72 76
 
73 77
     /**

+ 12
- 12
package.bluej Dosyayı Görüntüle

@@ -1,15 +1,15 @@
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=712
3
+editor.fx.0.width=876
4
+editor.fx.0.x=365
5
+editor.fx.0.y=189
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
-package.editor.x=59
12
+package.editor.x=85
13 13
 package.editor.y=63
14 14
 package.frame.height=600
15 15
 package.frame.width=1195
@@ -37,13 +37,13 @@ target2.type=UnitTestTargetJunit4
37 37
 target2.width=140
38 38
 target2.x=490
39 39
 target2.y=70
40
-target3.height=50
40
+target3.height=160
41 41
 target3.name=MathUtilities
42 42
 target3.showInterface=false
43 43
 target3.type=ClassTarget
44
-target3.width=100
45
-target3.x=60
46
-target3.y=150
44
+target3.width=190
45
+target3.x=40
46
+target3.y=200
47 47
 target4.height=50
48 48
 target4.name=StringUtilities
49 49
 target4.showInterface=false