|
|
|
|
1
|
## Building Utility Class for String Array Objects
|
1
|
## Building Utility Class for String Array Objects
|
2
|
* **Objective**
|
2
|
* **Objective**
|
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)
|
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
|
* **Purpose**
|
17
|
* **Purpose**
|
9
|
* To establish greater familiarity with loops and arrays.
|
18
|
* To establish greater familiarity with loops and arrays.
|
|
|
|
|
23
|
|
32
|
|
24
|
|
33
|
|
25
|
<br><br><br><br>
|
34
|
<br><br><br><br>
|
26
|
-## `getFirstElement(array)`
|
|
|
|
|
35
|
+## `String getFirstElement(String[] array)`
|
27
|
* **Description**
|
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
|
### Example 1
|
39
|
### Example 1
|
31
|
* Sample Script
|
40
|
* Sample Script
|
|
|
|
|
105
|
|
114
|
|
106
|
|
115
|
|
107
|
<br><br><br><br>
|
116
|
<br><br><br><br>
|
108
|
-## `getSecondElement(array)`
|
|
|
|
|
117
|
+## `String getSecondElement(String[] array)`
|
109
|
* **Description**
|
118
|
* **Description**
|
110
|
* Given an array of `String` objects, return the first element of the array.
|
119
|
* Given an array of `String` objects, return the first element of the array.
|
111
|
|
120
|
|
|
|
|
|
204
|
|
213
|
|
205
|
|
214
|
|
206
|
<br><br><br><br>
|
215
|
<br><br><br><br>
|
207
|
-## `getLastElement(array)`
|
|
|
|
|
216
|
+## `String getLastElement(String[] array)`
|
208
|
* **Description**
|
217
|
* **Description**
|
209
|
* Given an array of `String` objects, return the last element of the array.
|
218
|
* Given an array of `String` objects, return the last element of the array.
|
210
|
|
219
|
|
|
|
|
|
287
|
|
296
|
|
288
|
|
297
|
|
289
|
<br><br><br><br>
|
298
|
<br><br><br><br>
|
290
|
-## `getSecondToLastElement(array)`
|
|
|
|
|
299
|
+## ## `String getSecondToLastElement(String[] array)`
|
291
|
* **Description**
|
300
|
* **Description**
|
292
|
* Given an array of `String` objects, return the next-to-last element of the array.
|
301
|
* Given an array of `String` objects, return the next-to-last element of the array.
|
293
|
|
302
|
|
|
|
|
|
375
|
|
384
|
|
376
|
|
385
|
|
377
|
<br><br><br><br>
|
386
|
<br><br><br><br>
|
378
|
-## `contains(array, value)`
|
|
|
|
|
387
|
+## `boolean contains(String[] array, String value)`
|
379
|
* **Description**
|
388
|
* **Description**
|
380
|
* Given an array of `String` objects named `array` and a `String` object named `value`<br>return true if `value` appears in `arrays`.
|
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
|
|
449
|
|
441
|
|
450
|
|
442
|
<br><br><br><br>
|
451
|
<br><br><br><br>
|
443
|
-## `reverse(array)`
|
|
|
|
|
452
|
+## `String[] reverse(String[] array)`
|
444
|
* **Description**
|
453
|
* **Description**
|
445
|
* Given an array of `String` objects, return an array with identical contents in reverse order.
|
454
|
* Given an array of `String` objects, return an array with identical contents in reverse order.
|
446
|
|
455
|
|
|
|
|
|
542
|
|
551
|
|
543
|
|
552
|
|
544
|
<br><br><br><br>
|
553
|
<br><br><br><br>
|
545
|
-## `isPalindromic(array)`
|
|
|
|
|
554
|
+## `boolean isPalindromic(String[] array)`
|
546
|
* **Description**
|
555
|
* **Description**
|
547
|
* A [palindrome](http://www.dictionary.com/browse/palindromic) is a sequence that is the same backwards and forwards.
|
556
|
* A [palindrome](http://www.dictionary.com/browse/palindromic) is a sequence that is the same backwards and forwards.
|
548
|
* Given an array of `String` objects, return `true` if the array is palindromic.
|
557
|
* Given an array of `String` objects, return `true` if the array is palindromic.
|
|
|
|
|
639
|
|
648
|
|
640
|
|
649
|
|
641
|
<br><br><br><br>
|
650
|
<br><br><br><br>
|
642
|
-## `isPangramic(array)`
|
|
|
|
|
651
|
+## `boolean isPangramic(String[] array)`
|
643
|
* **Description**
|
652
|
* **Description**
|
644
|
* A [pangram](http://www.dictionary.com/browse/pangram) is a sequence that contains all letters of the alphabet.
|
653
|
* A [pangram](http://www.dictionary.com/browse/pangram) is a sequence that contains all letters of the alphabet.
|
645
|
* Given an array of `String` objects, return `true` if the array is palindromic.
|
654
|
* Given an array of `String` objects, return `true` if the array is palindromic.
|
|
|
|
|
703
|
|
712
|
|
704
|
|
713
|
|
705
|
<br><br><br><br>
|
714
|
<br><br><br><br>
|
706
|
-## `getNumberOfOccurrences(array, value)`
|
|
|
|
|
715
|
+## `int getNumberOfOccurrences(String[] array, String value)`
|
707
|
* **Description**
|
716
|
* **Description**
|
708
|
* Given an array of `String` objects named `array` and a `String` object named `value`<br>return the number of times `value` appears in `arrays`
|
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
|
|
827
|
|
819
|
|
828
|
|
820
|
<br><br><br><br>
|
829
|
<br><br><br><br>
|
821
|
-## `removeConsecutiveDuplicates(array)`
|
|
|
|
|
830
|
+## `String[] removeConsecutiveDuplicates(String[] array, String value)`
|
822
|
* **Description**
|
831
|
* **Description**
|
823
|
* Given an array of `String` objects, return an array of Strings with conseuctive duplicates removed.
|
832
|
* Given an array of `String` objects, return an array of Strings with conseuctive duplicates removed.
|
824
|
|
833
|
|
|
|
|
|
912
|
|
921
|
|
913
|
|
922
|
|
914
|
<br><br><br><br>
|
923
|
<br><br><br><br>
|
915
|
-## `packConsecutiveDuplicates(array)`
|
|
|
|
|
924
|
+## `String[] packConsecutiveDuplicates(String[] array)`
|
916
|
* **Description**
|
925
|
* **Description**
|
917
|
* Given an array of `char` objects, return an array of Strings with consecutive duplicates placed in an array.
|
926
|
* Given an array of `char` objects, return an array of Strings with consecutive duplicates placed in an array.
|
918
|
|
927
|
|
|
|
|
|
1019
|
|
1028
|
|
1020
|
|
1029
|
|
1021
|
<br><br><br><br>
|
1030
|
<br><br><br><br>
|
1022
|
-## `removeValues(array, valueToRemove)`
|
|
|
|
|
1031
|
+## `String[] removeValues(String[] array, String valueToRemove)`
|
1023
|
* **Description**
|
1032
|
* **Description**
|
1024
|
* 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.
|
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
|
|