소스 검색

String Functions

Yesoda Sanka 6 년 전
부모
커밋
abdc91984f
10개의 변경된 파일146개의 추가작업 그리고 87개의 파일을 삭제
  1. BIN
      MathUtilities.class
  2. 5
    5
      MathUtilities.ctxt
  3. 37
    31
      MathUtilities.java
  4. BIN
      MathUtilitiesTest.class
  5. 19
    27
      MathUtilitiesTest.java
  6. BIN
      PredicateUtilities.class
  7. 28
    5
      PredicateUtilities.java
  8. BIN
      StringUtilities.class
  9. 48
    13
      StringUtilities.java
  10. 9
    6
      package.bluej

BIN
MathUtilities.class 파일 보기


+ 5
- 5
MathUtilities.ctxt 파일 보기

1
 #BlueJ class context
1
 #BlueJ class context
2
 comment0.target=MathUtilities
2
 comment0.target=MathUtilities
3
 comment0.text=\n\ Created\ by\ dan\ on\ 6/14/17.\n
3
 comment0.text=\n\ Created\ by\ dan\ on\ 6/14/17.\n
4
-comment1.params=baseValue\ difference
4
+comment1.params=baseValue\ addedValue
5
 comment1.target=java.lang.Integer\ add(int,\ int)
5
 comment1.target=java.lang.Integer\ add(int,\ int)
6
 comment1.text=\n\ @param\ baseValue\ \ starting\ value\n\ @param\ difference\ value\ to\ add\ to\ starting\ value\n\ @return\ sum\ of\ `baseValue`\ and\ `difference`\n
6
 comment1.text=\n\ @param\ baseValue\ \ starting\ value\n\ @param\ difference\ value\ to\ add\ to\ starting\ value\n\ @return\ sum\ of\ `baseValue`\ and\ `difference`\n
7
 comment10.params=baseValue\ difference
7
 comment10.params=baseValue\ difference
58
 comment26.params=
58
 comment26.params=
59
 comment26.target=java.lang.Boolean\ returnFalse()
59
 comment26.target=java.lang.Boolean\ returnFalse()
60
 comment26.text=\n\ @return\ false\n
60
 comment26.text=\n\ @return\ false\n
61
-comment3.params=baseValue\ difference
61
+comment3.params=baseValue\ addedValue
62
 comment3.target=java.lang.Short\ add(short,\ short)
62
 comment3.target=java.lang.Short\ add(short,\ short)
63
 comment3.text=\n\ @param\ baseValue\ \ starting\ value\n\ @param\ difference\ value\ to\ add\ to\ starting\ value\n\ @return\ sum\ of\ `baseValue`\ and\ `difference`\n
63
 comment3.text=\n\ @param\ baseValue\ \ starting\ value\n\ @param\ difference\ value\ to\ add\ to\ starting\ value\n\ @return\ sum\ of\ `baseValue`\ and\ `difference`\n
64
-comment4.params=baseValue\ difference
64
+comment4.params=baseValue\ addedValue
65
 comment4.target=java.lang.Byte\ add(byte,\ byte)
65
 comment4.target=java.lang.Byte\ add(byte,\ byte)
66
 comment4.text=\n\ @param\ baseValue\ \ starting\ value\n\ @param\ difference\ value\ to\ add\ to\ starting\ value\n\ @return\ sum\ of\ `baseValue`\ and\ `difference`\n
66
 comment4.text=\n\ @param\ baseValue\ \ starting\ value\n\ @param\ difference\ value\ to\ add\ to\ starting\ value\n\ @return\ sum\ of\ `baseValue`\ and\ `difference`\n
67
-comment5.params=baseValue\ difference
67
+comment5.params=baseValue\ addedValue
68
 comment5.target=java.lang.Float\ add(float,\ float)
68
 comment5.target=java.lang.Float\ add(float,\ float)
69
 comment5.text=\n\ @param\ baseValue\ \ starting\ value\n\ @param\ difference\ value\ to\ add\ to\ starting\ value\n\ @return\ sum\ of\ `baseValue`\ and\ `difference`\n
69
 comment5.text=\n\ @param\ baseValue\ \ starting\ value\n\ @param\ difference\ value\ to\ add\ to\ starting\ value\n\ @return\ sum\ of\ `baseValue`\ and\ `difference`\n
70
-comment6.params=baseValue\ difference
70
+comment6.params=baseValue\ addedValue
71
 comment6.target=java.lang.Double\ add(double,\ double)
71
 comment6.target=java.lang.Double\ add(double,\ double)
72
 comment6.text=\n\ @param\ baseValue\ \ starting\ value\n\ @param\ difference\ value\ to\ add\ to\ starting\ value\n\ @return\ sum\ of\ `baseValue`\ and\ `difference`\n
72
 comment6.text=\n\ @param\ baseValue\ \ starting\ value\n\ @param\ difference\ value\ to\ add\ to\ starting\ value\n\ @return\ sum\ of\ `baseValue`\ and\ `difference`\n
73
 comment7.params=baseValue\ difference
73
 comment7.params=baseValue\ difference

+ 37
- 31
MathUtilities.java 파일 보기

10
      * @param difference value to add to starting value
10
      * @param difference value to add to starting value
11
      * @return sum of `baseValue` and `difference`
11
      * @return sum of `baseValue` and `difference`
12
      */
12
      */
13
-    public Integer add(int baseValue, int difference) {
14
-        return null;
13
+    public Integer add(int baseValue, int addedValue ) {
14
+       
15
+        int sum;
16
+        sum= baseValue + addedValue;
17
+        return sum;
18
+        
15
     }
19
     }
16
 
20
 
17
     /**
21
     /**
20
      * @return sum of `baseValue` and `difference`
24
      * @return sum of `baseValue` and `difference`
21
      */
25
      */
22
     public Long add(long baseValue, long difference) {
26
     public Long add(long baseValue, long difference) {
23
-        return null;
27
+        long diff= baseValue + difference;
28
+        return diff;
29
+        
24
     }
30
     }
25
 
31
 
26
     /**
32
     /**
28
      * @param difference value to add to starting value
34
      * @param difference value to add to starting value
29
      * @return sum of `baseValue` and `difference`
35
      * @return sum of `baseValue` and `difference`
30
      */
36
      */
31
-    public Short add(short baseValue, short difference) {
32
-        return null;
37
+    public Short add(short baseValue, short addedValue) {
38
+       return (short)(baseValue + addedValue);
33
     }
39
     }
34
 
40
 
35
     /**
41
     /**
37
      * @param difference value to add to starting value
43
      * @param difference value to add to starting value
38
      * @return sum of `baseValue` and `difference`
44
      * @return sum of `baseValue` and `difference`
39
      */
45
      */
40
-    public Byte add(byte baseValue, byte difference) {
41
-        return null;
46
+    public Byte add(byte baseValue, byte addedValue) {
47
+       return (byte)(baseValue + addedValue);
42
     }
48
     }
43
 
49
 
44
     /**
50
     /**
46
      * @param difference value to add to starting value
52
      * @param difference value to add to starting value
47
      * @return sum of `baseValue` and `difference`
53
      * @return sum of `baseValue` and `difference`
48
      */
54
      */
49
-    public Float add(float baseValue, float difference) {
50
-        return null;
55
+    public Float add(float baseValue, float addedValue) {
56
+        return (float)(baseValue + addedValue);
51
     }
57
     }
52
 
58
 
53
     /**
59
     /**
55
      * @param difference value to add to starting value
61
      * @param difference value to add to starting value
56
      * @return sum of `baseValue` and `difference`
62
      * @return sum of `baseValue` and `difference`
57
      */
63
      */
58
-    public Double add(double baseValue, double difference) {
59
-        return null;
64
+    public Double add(double baseValue, double addedValue) {
65
+        return (double)(baseValue + addedValue);
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
+        return (int)(baseValue - difference);
69
     }
75
     }
70
 
76
 
71
     /**
77
     /**
74
      * @return difference between `baseValue` and `difference`
80
      * @return difference between `baseValue` and `difference`
75
      */
81
      */
76
     public Long subtract(long baseValue, long difference) {
82
     public Long subtract(long baseValue, long difference) {
77
-        return null;
83
+        return (long)(baseValue - difference);
78
     }
84
     }
79
 
85
 
80
     /**
86
     /**
83
      * @return difference between `baseValue` and `difference`
89
      * @return difference between `baseValue` and `difference`
84
      */
90
      */
85
     public Short subtract(short baseValue, short difference) {
91
     public Short subtract(short baseValue, short difference) {
86
-        return null;
92
+        return (short)(baseValue - difference);
87
     }
93
     }
88
 
94
 
89
     /**
95
     /**
92
      * @return difference between `baseValue` and `difference`
98
      * @return difference between `baseValue` and `difference`
93
      */
99
      */
94
     public Byte subtract(byte baseValue, byte difference) {
100
     public Byte subtract(byte baseValue, byte difference) {
95
-        return null;
101
+        return (byte)(baseValue - difference);
96
     }
102
     }
97
 
103
 
98
     /**
104
     /**
101
      * @return difference between `baseValue` and `difference`
107
      * @return difference between `baseValue` and `difference`
102
      */
108
      */
103
     public Float subtract(float baseValue, float difference) {
109
     public Float subtract(float baseValue, float difference) {
104
-        return null;
110
+        return (float)(baseValue - difference);
105
     }
111
     }
106
 
112
 
107
     /**
113
     /**
110
      * @return difference between `baseValue` and `difference`
116
      * @return difference between `baseValue` and `difference`
111
      */
117
      */
112
     public Double subtract(double baseValue, double difference) {
118
     public Double subtract(double baseValue, double difference) {
113
-        return null;
119
+        return  (double)(baseValue - difference);
114
     }
120
     }
115
 
121
 
116
 
122
 
120
      * @return division of `dividend` by `divisor
126
      * @return division of `dividend` by `divisor
121
      */
127
      */
122
     public Integer divide(int dividend, int divisor) {
128
     public Integer divide(int dividend, int divisor) {
123
-        return null;
129
+        return (int)(dividend / divisor);
124
     }
130
     }
125
 
131
 
126
     /**
132
     /**
129
      * @return division of `dividend` by `divisor
135
      * @return division of `dividend` by `divisor
130
      */
136
      */
131
     public Long divide(long dividend, long divisor) {
137
     public Long divide(long dividend, long divisor) {
132
-        return null;
138
+        return (long)(dividend / divisor);
133
     }
139
     }
134
 
140
 
135
     /**
141
     /**
138
      * @return division of `dividend` by `divisor
144
      * @return division of `dividend` by `divisor
139
      */
145
      */
140
     public Short divide(short dividend, short divisor) {
146
     public Short divide(short dividend, short divisor) {
141
-        return null;
147
+        return (short) ( dividend /divisor);
142
     }
148
     }
143
 
149
 
144
     /**
150
     /**
147
      * @return division of `dividend` by `divisor
153
      * @return division of `dividend` by `divisor
148
      */
154
      */
149
     public Byte divide(byte dividend, byte divisor) {
155
     public Byte divide(byte dividend, byte divisor) {
150
-        return null;
156
+        return (byte)(dividend / divisor);
151
     }
157
     }
152
 
158
 
153
     /**
159
     /**
156
      * @return division of `dividend` by `divisor
162
      * @return division of `dividend` by `divisor
157
      */
163
      */
158
     public Float divide(float dividend, float divisor) {
164
     public Float divide(float dividend, float divisor) {
159
-        return null;
165
+        return (float)(dividend / divisor);
160
     }
166
     }
161
 
167
 
162
     /**
168
     /**
165
      * @return division of `dividend` by `divisor
171
      * @return division of `dividend` by `divisor
166
      */
172
      */
167
     public Double divide(double dividend, double divisor) {
173
     public Double divide(double dividend, double divisor) {
168
-        return null;
174
+        return (double)(dividend / divisor);
169
     }
175
     }
170
 
176
 
171
 
177
 
175
      * @return product of `multiplicand` by `multiplier`
181
      * @return product of `multiplicand` by `multiplier`
176
      */
182
      */
177
     public Integer multiply(int multiplicand, int multiplier) {
183
     public Integer multiply(int multiplicand, int multiplier) {
178
-        return null;
184
+        return (int)(multiplicand * multiplier);
179
     }
185
     }
180
 
186
 
181
     /**
187
     /**
184
      * @return product of `multiplicand` by `multiplier`
190
      * @return product of `multiplicand` by `multiplier`
185
      */
191
      */
186
     public Long multiply(long multiplicand, long multiplier) {
192
     public Long multiply(long multiplicand, long multiplier) {
187
-        return null;
193
+        return (long)(multiplicand * multiplier);
188
     }
194
     }
189
 
195
 
190
     /**
196
     /**
193
      * @return product of `multiplicand` by `multiplier`
199
      * @return product of `multiplicand` by `multiplier`
194
      */
200
      */
195
     public Short multiply(short multiplicand, short multiplier) {
201
     public Short multiply(short multiplicand, short multiplier) {
196
-        return null;
202
+        return (short)(multiplicand * multiplier);
197
     }
203
     }
198
     /**
204
     /**
199
      * @param multiplicand value to be multiplied
205
      * @param multiplicand value to be multiplied
201
      * @return product of `multiplicand` by `multiplier`
207
      * @return product of `multiplicand` by `multiplier`
202
      */
208
      */
203
     public Byte multiply(byte multiplicand, byte multiplier) {
209
     public Byte multiply(byte multiplicand, byte multiplier) {
204
-        return null;
210
+        return (byte)(multiplicand * multiplier);
205
     }
211
     }
206
 
212
 
207
     /**
213
     /**
210
      * @return product of `multiplicand` by `multiplier`
216
      * @return product of `multiplicand` by `multiplier`
211
      */
217
      */
212
     public Float multiply(float multiplicand, float multiplier) {
218
     public Float multiply(float multiplicand, float multiplier) {
213
-        return null;
219
+        return (float)(multiplicand * multiplier);
214
     }
220
     }
215
 
221
 
216
     /**
222
     /**
219
      * @return product of `multiplicand` by `multiplier`
225
      * @return product of `multiplicand` by `multiplier`
220
      */
226
      */
221
     public Double multiply(double multiplicand, double multiplier) {
227
     public Double multiply(double multiplicand, double multiplier) {
222
-        return null;
228
+        return (double)(multiplicand * multiplier);
223
     }
229
     }
224
 
230
 
225
 
231
 
227
       * @return true
233
       * @return true
228
      */
234
      */
229
     public Boolean returnTrue() {
235
     public Boolean returnTrue() {
230
-        return null;
236
+        return true;
231
     }
237
     }
232
 
238
 
233
     /**
239
     /**
234
      * @return false
240
      * @return false
235
      */
241
      */
236
     public Boolean returnFalse() {
242
     public Boolean returnFalse() {
237
-        return null;
243
+        return false;
238
     }
244
     }
239
 
245
 
240
 }
246
 }

BIN
MathUtilitiesTest.class 파일 보기


+ 19
- 27
MathUtilitiesTest.java 파일 보기

1
- 
2
 
1
 
3
 import org.junit.Test;
2
 import org.junit.Test;
4
-
5
 import static org.junit.Assert.*;
3
 import static org.junit.Assert.*;
6
 /**
4
 /**
7
  * Created by dan on 6/14/17.
5
  * Created by dan on 6/14/17.
16
         int addedValue = 7;
14
         int addedValue = 7;
17
         int expected = 27;
15
         int expected = 27;
18
         // : When
16
         // : When
19
-        int actual = primativeTypes.add(baseValue, addedValue);
17
+        int actual = primativeTypes.add(baseValue,addedValue);
20
         // : Then
18
         // : Then
21
         assertEquals(expected,actual);
19
         assertEquals(expected,actual);
22
     }
20
     }
21
+
23
     @Test
22
     @Test
24
     public void testAdditions1() {
23
     public void testAdditions1() {
25
         // : Given
24
         // : Given
31
         // : Then
30
         // : Then
32
         assertEquals(expected,actual);
31
         assertEquals(expected,actual);
33
     }
32
     }
33
+
34
     @Test
34
     @Test
35
     public void testAdditions2() {
35
     public void testAdditions2() {
36
         // : Given
36
         // : Given
54
         // : Then
54
         // : Then
55
         assertEquals(expected,actual);
55
         assertEquals(expected,actual);
56
     }
56
     }
57
+
57
     @Test
58
     @Test
58
     public void testAdditions5() {
59
     public void testAdditions5() {
59
         // : Given
60
         // : Given
85
 
86
 
86
 
87
 
87
 
88
 
88
-
89
-
90
-
91
-
92
-
93
-
94
-
95
-
96
     @Test
89
     @Test
97
     public void testSubtractions(){
90
     public void testSubtractions(){
98
         // : Given
91
         // : Given
104
         // : Then
97
         // : Then
105
         assertEquals(expectedInt,actualInt);
98
         assertEquals(expectedInt,actualInt);
106
     }
99
     }
100
+
107
     @Test
101
     @Test
108
     public void testSubtractions1() {
102
     public void testSubtractions1() {
109
         // : Given
103
         // : Given
115
         // : Then
109
         // : Then
116
         assertEquals(expectedLong,actualLong);
110
         assertEquals(expectedLong,actualLong);
117
     }
111
     }
112
+
118
     @Test
113
     @Test
119
     public void testSubtractions2() {
114
     public void testSubtractions2() {
120
         // : Given
115
         // : Given
126
         // : Then
121
         // : Then
127
         assertEquals(expectedShort,actualShort);
122
         assertEquals(expectedShort,actualShort);
128
     }
123
     }
124
+
129
     @Test
125
     @Test
130
     public void testSubtractions3() {
126
     public void testSubtractions3() {
131
         // : Given
127
         // : Given
137
         // : Then
133
         // : Then
138
         assertEquals(expectedByte,actualByte);
134
         assertEquals(expectedByte,actualByte);
139
     }
135
     }
136
+
140
     @Test
137
     @Test
141
     public void testSubtractions4() {
138
     public void testSubtractions4() {
142
         // : Given
139
         // : Given
148
         // : Then
145
         // : Then
149
         assertEquals(expectedFloat,actualFloat, 0.005);
146
         assertEquals(expectedFloat,actualFloat, 0.005);
150
     }
147
     }
148
+
151
     @Test
149
     @Test
152
     public void testSubtractions5() {
150
     public void testSubtractions5() {
153
         // : Given
151
         // : Given
166
 
164
 
167
 
165
 
168
 
166
 
169
-
170
-
171
-
172
-
173
-
174
-
175
-
176
     @Test
167
     @Test
177
     public void testDivision(){
168
     public void testDivision(){
178
         // : Given
169
         // : Given
184
         // : Then
175
         // : Then
185
         assertEquals(expectedInt,actualInt);
176
         assertEquals(expectedInt,actualInt);
186
     }
177
     }
178
+
187
     @Test
179
     @Test
188
     public void testDivision1() {
180
     public void testDivision1() {
189
         // : Given
181
         // : Given
195
         // : Then
187
         // : Then
196
         assertEquals(expectedLong,actualLong);
188
         assertEquals(expectedLong,actualLong);
197
     }
189
     }
190
+
198
     @Test
191
     @Test
199
     public void testDivision2() {
192
     public void testDivision2() {
200
         // : Given
193
         // : Given
207
         assertEquals(expectedShort,actualShort);
200
         assertEquals(expectedShort,actualShort);
208
 
201
 
209
     }
202
     }
203
+
210
     @Test
204
     @Test
211
     public void testDivision3() {
205
     public void testDivision3() {
212
         // : Given
206
         // : Given
218
         // : Then
212
         // : Then
219
         assertEquals(expectedByte,actualByte);
213
         assertEquals(expectedByte,actualByte);
220
     }
214
     }
215
+
221
     @Test
216
     @Test
222
     public void testDivision4() {
217
     public void testDivision4() {
223
         // : Given
218
         // : Given
229
         // : Then
224
         // : Then
230
         assertEquals(expectedFloat,actualFloat, 0);
225
         assertEquals(expectedFloat,actualFloat, 0);
231
     }
226
     }
227
+
232
     @Test
228
     @Test
233
     public void testDivision5() {
229
     public void testDivision5() {
234
         // : Given
230
         // : Given
249
 
245
 
250
 
246
 
251
 
247
 
252
-
253
-
254
-
255
-
256
-
257
-
258
-
259
-
260
-
261
     @Test
248
     @Test
262
     public void testMultiplication(){
249
     public void testMultiplication(){
263
         // : Given
250
         // : Given
269
         // : Then
256
         // : Then
270
         assertEquals(expectedInt,actualInt);
257
         assertEquals(expectedInt,actualInt);
271
     }
258
     }
259
+
272
     @Test
260
     @Test
273
     public void testMultiplication1() {
261
     public void testMultiplication1() {
274
         // : Given
262
         // : Given
280
         // : Then
268
         // : Then
281
         assertEquals(expectedLong, actualLong);
269
         assertEquals(expectedLong, actualLong);
282
     }
270
     }
271
+
283
     @Test
272
     @Test
284
     public void testMultiplication2() {
273
     public void testMultiplication2() {
285
         // : Given
274
         // : Given
291
         // : Then
280
         // : Then
292
         assertEquals(expectedShort, actualShort);
281
         assertEquals(expectedShort, actualShort);
293
     }
282
     }
283
+
294
     @Test
284
     @Test
295
     public void testMultiplication3() {
285
     public void testMultiplication3() {
296
         // : Given
286
         // : Given
302
         // : Then
292
         // : Then
303
         assertEquals(expectedByte, actualByte);
293
         assertEquals(expectedByte, actualByte);
304
     }
294
     }
295
+
305
     @Test
296
     @Test
306
     public void testMultiplication4() {
297
     public void testMultiplication4() {
307
         // : Given
298
         // : Given
313
         // : Then
304
         // : Then
314
         assertEquals(expectedFloat, actualFloat, 0);
305
         assertEquals(expectedFloat, actualFloat, 0);
315
     }
306
     }
307
+
316
     @Test
308
     @Test
317
     public void testMultiplication5() {
309
     public void testMultiplication5() {
318
         // : Given
310
         // : Given

BIN
PredicateUtilities.class 파일 보기


+ 28
- 5
PredicateUtilities.java 파일 보기

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
+       {
15
+        return true;
14
     }
16
     }
15
-
17
+    else
18
+    { return false;
19
+    }
20
+}
16
     /**
21
     /**
17
      * @param x
22
      * @param x
18
      * @param y
23
      * @param y
19
      * @return true if `x` is less than `y`
24
      * @return true if `x` is less than `y`
20
      */
25
      */
21
     public Boolean isLessThan(int x, int y) {
26
     public Boolean isLessThan(int x, int y) {
22
-        return null;
27
+         if(x<y)
28
+       {
29
+        return true;
30
+    }
31
+    else
32
+    { return false;
33
+    }
23
     }
34
     }
24
 
35
 
25
     /**
36
     /**
28
      * @return true if `x` is greater than or equal to `y`
39
      * @return true if `x` is greater than or equal to `y`
29
      */
40
      */
30
     public Boolean isGreaterThanOrEqualTo(int x, int y) {
41
     public Boolean isGreaterThanOrEqualTo(int x, int y) {
31
-        return null;
42
+         if(x == y)
43
+       {
44
+        return true;
45
+    }
46
+    else
47
+    { return false;
48
+    }
32
     }
49
     }
33
 
50
 
34
     /**
51
     /**
37
      * @return true if `x` is less than or equal to `y`
54
      * @return true if `x` is less than or equal to `y`
38
      */
55
      */
39
     public Boolean isLessThanOrEqualTo(int x, int y) {
56
     public Boolean isLessThanOrEqualTo(int x, int y) {
40
-        return null;
57
+         if(x<=y)
58
+       {
59
+        return true;
60
+    }
61
+    else
62
+    { return false;
63
+    }
41
     }
64
     }
42
 }
65
 }

BIN
StringUtilities.class 파일 보기


+ 48
- 13
StringUtilities.java 파일 보기

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 World";
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
+        //StringBuilder sb=new StringBuilder().append(firstSegment).append(secondSegment);
20
+        //return sb.toString();
21
+        return (firstSegment + secondSegment);
22
+
21
     }
23
     }
22
 
24
 
23
     /**
25
     /**
26
      * @return the concatenation of an integer, `firstSegment`, and a String, `secondSegment`
28
      * @return the concatenation of an integer, `firstSegment`, and a String, `secondSegment`
27
      */
29
      */
28
     public static String concatenation(int firstSegment, String secondSegment){
30
     public static String concatenation(int firstSegment, String secondSegment){
29
-        return null;
31
+        StringBuilder sum=new StringBuilder().append(firstSegment).append(secondSegment);
32
+        return sum.toString();
30
     }
33
     }
31
 
34
 
32
     /**
35
     /**
34
      * @return the first 3 characters of `input`
37
      * @return the first 3 characters of `input`
35
      */
38
      */
36
     public static String getPrefix(String input){
39
     public static String getPrefix(String input){
37
-        return null;
40
+        String str=input.substring(0,3);
41
+        return str;
38
     }
42
     }
39
 
43
 
40
     /**
44
     /**
42
      * @return the last 3 characters of `input`
46
      * @return the last 3 characters of `input`
43
      */
47
      */
44
     public static String getSuffix(String input){
48
     public static String getSuffix(String input){
45
-        return null;
49
+        String str=input.substring(input.length() - 3);
50
+        return str;
46
     }
51
     }
47
 
52
 
48
     /**
53
     /**
51
      * @return the equivalence of two strings, `inputValue` and `comparableValue`
56
      * @return the equivalence of two strings, `inputValue` and `comparableValue`
52
      */
57
      */
53
     public static Boolean compareTwoStrings(String inputValue, String comparableValue){
58
     public static Boolean compareTwoStrings(String inputValue, String comparableValue){
54
-        return null;
59
+
60
+        boolean val =inputValue.equalsIgnoreCase(comparableValue);
61
+        return val;
62
+
55
     }
63
     }
56
 
64
 
57
     /**
65
     /**
59
      * @return the middle character of `inputValue`
67
      * @return the middle character of `inputValue`
60
      */
68
      */
61
     public static Character getMiddleCharacter(String inputValue){
69
     public static Character getMiddleCharacter(String inputValue){
62
-        return null;
70
+        int len = inputValue.length();
71
+        char ch[]=inputValue.toCharArray();
72
+        int c = len/2;
73
+          if(len%2 == 0)
74
+          {
75
+              return ch [c-1];
76
+            }          
77
+        else
78
+        {
79
+            
80
+            return ch[c];
81
+        } 
82
+      
63
     }
83
     }
64
-
65
     /**
84
     /**
66
      * @param spaceDelimitedString a string, representative of a sentence, containing spaces
85
      * @param spaceDelimitedString a string, representative of a sentence, containing spaces
67
      * @return the first sequence of characters
86
      * @return the first sequence of characters
68
      */
87
      */
69
     public static String getFirstWord(String spaceDelimitedString){
88
     public static String getFirstWord(String spaceDelimitedString){
70
-        return null;
89
+        String[] result=spaceDelimitedString.split(" ");
90
+        /*for(int i = 0; i < spaceDelimitedString.length(); i++)
91
+        {
92
+            if(spaceDelimitedString.charAt(i) == ' ')
93
+            {
94
+                result = spaceDelimitedString.substring(0, i);
95
+                break;
96
+            }
97
+        }*/
98
+        return result[0];
99
+
71
     }
100
     }
72
 
101
 
73
     /**
102
     /**
74
      * @param spaceDelimitedString a string delimited by spaces
103
      * @param spaceDelimitedString a string delimited by spaces
75
      * @return the second word of a string delimited by spaces.
104
      * @return the second word of a string delimited by spaces.
76
      */
105
      */
77
-    public static String getSecondWord(String spaceDelimitedString){
78
-        return null;
106
+    public static String getSecondWord(String spaceDelimitedString)
107
+
108
+    {
109
+       String[] str=spaceDelimitedString.split(" ");
110
+       return str[1];
79
     }
111
     }
80
 
112
 
81
     /**
113
     /**
83
      * @return an identical string with characters in reverse order.
115
      * @return an identical string with characters in reverse order.
84
      */
116
      */
85
     public static String reverse(String stringToReverse){
117
     public static String reverse(String stringToReverse){
86
-        return null;
118
+        StringBuilder a = new StringBuilder(stringToReverse);
119
+        String str=a.reverse().toString();
120
+
121
+        return str;
87
     }
122
     }
88
 }
123
 }

+ 9
- 6
package.bluej 파일 보기

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
+dependency1.from=MathUtilitiesTest
3
+dependency1.to=MathUtilities
4
+dependency1.type=UsesDependency
5
+editor.fx.0.height=714
6
+editor.fx.0.width=800
7
+editor.fx.0.x=240
8
+editor.fx.0.y=23
6
 objectbench.height=129
9
 objectbench.height=129
7
-objectbench.width=1171
10
+objectbench.width=698
8
 package.divider.horizontal=0.6
11
 package.divider.horizontal=0.6
9
 package.divider.vertical=0.7490774907749077
12
 package.divider.vertical=0.7490774907749077
10
 package.editor.height=399
13
 package.editor.height=399
13
 package.editor.y=63
16
 package.editor.y=63
14
 package.frame.height=600
17
 package.frame.height=600
15
 package.frame.width=1195
18
 package.frame.width=1195
16
-package.numDependencies=0
19
+package.numDependencies=1
17
 package.numTargets=6
20
 package.numTargets=6
18
 package.showExtends=true
21
 package.showExtends=true
19
 package.showUses=true
22
 package.showUses=true