|
@@ -1,9 +1,18 @@
|
1
|
1
|
## Building Utility Class for String Array Objects
|
2
|
2
|
* **Objective**
|
3
|
3
|
* Ensure [StringArrayUtilsTest](https://github.com/Zipcoder/CR-MicroLabs-Arrays-StringArrayUtilities/blob/master/src/test/java/com/zipcodewilmington/StringArrayUtilsTest.java) passes each test by completing the methods [stubbed out](https://en.wikipedia.org/wiki/Method_stub) in the class [StringArrayUtils](https://github.com/Zipcoder/CR-MicroLabs-Arrays-StringArrayUtilities/blob/master/src/main/java/com/zipcodewilmington/StringArrayUtils.java)
|
4
|
|
- * `int getNumberOfOccurrences(String[] stringArray, String stringToCheck)`
|
5
|
|
- * `boolean contains(String[] stringArray, String stringToCheck)`
|
6
|
|
- * `String[] removeValue(String[] stringArray, String stringToRemove)`
|
|
4
|
+ * `String getFirstElement(String[] array)`
|
|
5
|
+ * `String getSecondElement(String[] array)`
|
|
6
|
+ * `String getLastElement(String[] array)`
|
|
7
|
+ * `String getSecondToLastElement(String[] array)`
|
|
8
|
+ * `boolean contains(String[] array, String value)`
|
|
9
|
+ * `String[] reverse(String[] array)`
|
|
10
|
+ * `boolean isPalindromic(String[] array)`
|
|
11
|
+ * `boolean isPangramic(String[] array)`
|
|
12
|
+ * `int getNumberOfOccurrences(String[] array, String value)`
|
|
13
|
+ * `String[] removeValue(String[] array, String value)`
|
|
14
|
+ * `String[] removeConsecutiveDuplicates(String[] array, String value)`
|
|
15
|
+ * `String[] packConsecutiveDuplicates(String[] array, String value)`
|
7
|
16
|
|
8
|
17
|
* **Purpose**
|
9
|
18
|
* To establish greater familiarity with loops and arrays.
|
|
@@ -23,9 +32,9 @@
|
23
|
32
|
|
24
|
33
|
|
25
|
34
|
<br><br><br><br>
|
26
|
|
-## `getFirstElement(array)`
|
|
35
|
+## `String getFirstElement(String[] array)`
|
27
|
36
|
* **Description**
|
28
|
|
- * Given an array of `String` objects, return the first element of the array.
|
|
37
|
+ * Given an array of `String` objects, return the first element of the array.
|
29
|
38
|
|
30
|
39
|
### Example 1
|
31
|
40
|
* Sample Script
|
|
@@ -105,7 +114,7 @@
|
105
|
114
|
|
106
|
115
|
|
107
|
116
|
<br><br><br><br>
|
108
|
|
-## `getSecondElement(array)`
|
|
117
|
+## `String getSecondElement(String[] array)`
|
109
|
118
|
* **Description**
|
110
|
119
|
* Given an array of `String` objects, return the first element of the array.
|
111
|
120
|
|
|
@@ -204,7 +213,7 @@
|
204
|
213
|
|
205
|
214
|
|
206
|
215
|
<br><br><br><br>
|
207
|
|
-## `getLastElement(array)`
|
|
216
|
+## `String getLastElement(String[] array)`
|
208
|
217
|
* **Description**
|
209
|
218
|
* Given an array of `String` objects, return the last element of the array.
|
210
|
219
|
|
|
@@ -287,7 +296,7 @@
|
287
|
296
|
|
288
|
297
|
|
289
|
298
|
<br><br><br><br>
|
290
|
|
-## `getSecondToLastElement(array)`
|
|
299
|
+## ## `String getSecondToLastElement(String[] array)`
|
291
|
300
|
* **Description**
|
292
|
301
|
* Given an array of `String` objects, return the next-to-last element of the array.
|
293
|
302
|
|
|
@@ -375,7 +384,7 @@
|
375
|
384
|
|
376
|
385
|
|
377
|
386
|
<br><br><br><br>
|
378
|
|
-## `contains(array, value)`
|
|
387
|
+## `boolean contains(String[] array, String value)`
|
379
|
388
|
* **Description**
|
380
|
389
|
* Given an array of `String` objects named `array` and a `String` object named `value`<br>return true if `value` appears in `arrays`.
|
381
|
390
|
|
|
@@ -440,7 +449,7 @@
|
440
|
449
|
|
441
|
450
|
|
442
|
451
|
<br><br><br><br>
|
443
|
|
-## `reverse(array)`
|
|
452
|
+## `String[] reverse(String[] array)`
|
444
|
453
|
* **Description**
|
445
|
454
|
* Given an array of `String` objects, return an array with identical contents in reverse order.
|
446
|
455
|
|
|
@@ -542,7 +551,7 @@
|
542
|
551
|
|
543
|
552
|
|
544
|
553
|
<br><br><br><br>
|
545
|
|
-## `isPalindromic(array)`
|
|
554
|
+## `boolean isPalindromic(String[] array)`
|
546
|
555
|
* **Description**
|
547
|
556
|
* A [palindrome](http://www.dictionary.com/browse/palindromic) is a sequence that is the same backwards and forwards.
|
548
|
557
|
* Given an array of `String` objects, return `true` if the array is palindromic.
|
|
@@ -639,7 +648,7 @@
|
639
|
648
|
|
640
|
649
|
|
641
|
650
|
<br><br><br><br>
|
642
|
|
-## `isPangramic(array)`
|
|
651
|
+## `boolean isPangramic(String[] array)`
|
643
|
652
|
* **Description**
|
644
|
653
|
* A [pangram](http://www.dictionary.com/browse/pangram) is a sequence that contains all letters of the alphabet.
|
645
|
654
|
* Given an array of `String` objects, return `true` if the array is palindromic.
|
|
@@ -703,7 +712,7 @@
|
703
|
712
|
|
704
|
713
|
|
705
|
714
|
<br><br><br><br>
|
706
|
|
-## `getNumberOfOccurrences(array, value)`
|
|
715
|
+## `int getNumberOfOccurrences(String[] array, String value)`
|
707
|
716
|
* **Description**
|
708
|
717
|
* Given an array of `String` objects named `array` and a `String` object named `value`<br>return the number of times `value` appears in `arrays`
|
709
|
718
|
|
|
@@ -818,7 +827,7 @@
|
818
|
827
|
|
819
|
828
|
|
820
|
829
|
<br><br><br><br>
|
821
|
|
-## `removeConsecutiveDuplicates(array)`
|
|
830
|
+## `String[] removeConsecutiveDuplicates(String[] array, String value)`
|
822
|
831
|
* **Description**
|
823
|
832
|
* Given an array of `String` objects, return an array of Strings with conseuctive duplicates removed.
|
824
|
833
|
|
|
@@ -912,7 +921,7 @@
|
912
|
921
|
|
913
|
922
|
|
914
|
923
|
<br><br><br><br>
|
915
|
|
-## `packConsecutiveDuplicates(array)`
|
|
924
|
+## `String[] packConsecutiveDuplicates(String[] array)`
|
916
|
925
|
* **Description**
|
917
|
926
|
* Given an array of `char` objects, return an array of Strings with consecutive duplicates placed in an array.
|
918
|
927
|
|
|
@@ -1019,7 +1028,7 @@
|
1019
|
1028
|
|
1020
|
1029
|
|
1021
|
1030
|
<br><br><br><br>
|
1022
|
|
-## `removeValues(array, valueToRemove)`
|
|
1031
|
+## `String[] removeValues(String[] array, String valueToRemove)`
|
1023
|
1032
|
* **Description**
|
1024
|
1033
|
* Given an array of `String` objects named `array` and a `String` object named `valueToRemove`<br>create and return an array containing identical contents excluding objects whose value is equivalent to `valueToRemove`. Ensure that the length of the newly created array has been resized based on the removal of the undesired elements.
|
1025
|
1034
|
|