Skip to content

Commit

Permalink
updated test cases and readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Leon authored and Leon committed Jan 30, 2018
1 parent 243f190 commit 28c0c30
Show file tree
Hide file tree
Showing 3 changed files with 491 additions and 38 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@
<br><br><br><br>
## `getNextToLastElement(array)`
## `getSecondToLastElement(array)`
* **Description**
* Given an array of `String` objects, return the next-to-last element of the array.
Expand All @@ -299,7 +299,7 @@
String[] array = {"the", "quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog"};
// : When
boolean outcome = StringArrayUtils.getNextToLastElement(array);
boolean outcome = StringArrayUtils.getSecondToLastElement(array);
// : Then
System.out.println(outcome);
Expand Down Expand Up @@ -912,20 +912,20 @@
<br><br><br><br>
## `packDuplicates(array)`
## `packConsecutiveDuplicates(array)`
* **Description**
* Given an array of `char` objects, return an array of Strings with conseuctive duplicates placed in an array.
* Given an array of `char` objects, return an array of Strings with consecutive duplicates placed in an array.
### Example 1
* Sample Script
```
// : Given
char[] array = {'a' 'a' 'a' 'a' 'b' 'c' 'c' 'a' 'a' 'd'}
String[] array = {"a", "a", "a", "a", "b", "c", "c", "a", "a", "d"};
// : When
String[] actual = StringArrayUtils.packDuplicates(array);
String[] actual = StringArrayUtils.packConsecutiveDuplicates(array);
// : Then
System.out.println(Arrays.toString(actual));
Expand All @@ -950,10 +950,10 @@
```
// : Given
char[] array = {'t', 't', 'q', 'a' 'a' 'a' 'a' 'b'}
String[] array = {"t", "t", "q", "a", "a", "a", "b", "c", "c", "a", "a", "d", "e", "e", "e"};
// : When
String[] actual = StringArrayUtils.packDuplicates(array);
String[] actual = StringArrayUtils.packConsecutiveDuplicates(array);
// : Then
System.out.println(Arrays.toString(actual));
Expand All @@ -976,10 +976,10 @@
```
// : Given
char[] array = {'m', 'o', 'o', 'n' 'm' 'a' 'n'}
String[] array = {"m", "o", "o", "n", "m", "a", "n"}
// : When
String[] actual = StringArrayUtils.packDuplicates(array);
String[] actual = StringArrayUtils.packConsecutiveDuplicates(array);
// : Then
System.out.println(Arrays.toString(actual));
Expand Down
96 changes: 84 additions & 12 deletions src/main/java/com/zipcodewilmington/StringArrayUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,103 @@
*/
public class StringArrayUtils {
/**
* @param array - array of String objects
* @param value - value to check array for
* @return - number of occurrences the specified `value` has occurred
* @param array array of String objects
* @return first element of specified array
*/ // TODO
public static int getNumberOfOccurrences(String[] array, String value) {
return 0;
public static String getFirstElement(String[] array) {
return null;
}

/**
* @param array - array of String objects
* @param value - value to check array for
* @return - true if the array contains the specified `value`
* @param array array of String objects
* @return second element in specified array
*/
public static String getSecondElement(String[] array) {
return null;
}

/**
* @param array array of String objects
* @return last element in specified array
*/ // TODO
public static String getLastElement(String[] array) {
return null;
}

/**
* @param array array of String objects
* @return second to last element in specified array
*/ // TODO
public static String getSecondToLastElement(String[] array) {
return null;
}

/**
* @param array array of String objects
* @param value value to check array for
* @return true if the array contains the specified `value`
*/ // TODO
public static boolean contains(String[] array, String value) {
return false;
}

/**
* @param array of String objects
* @return an array with identical contents in reverse order
*/ // TODO
public static String[] reverse(String[] array) {
return null;
}

/**
* @param array - array of String objects
* @param valueToRemove - value to remove from array
* @return - array with identical contents excluding values of `value`
*/
* @param array array of String objects
* @return true if the order of the array is the same backwards and forwards
*/ // TODO
public static boolean isPalindromic(String[] array) {
return false;
}

/**
* @param array array of String objects
* @return true if each letter in the alphabet has been used in the array
*/ // TODO
public static boolean isPangramic(String[] array) {
return false;
}

/**
* @param array array of String objects
* @param value value to check array for
* @return number of occurrences the specified `value` has occurred
*/ // TODO
public static int getNumberOfOccurrences(String[] array, String value) {
return 0;
}

/**
* @param array array of String objects
* @param valueToRemove value to remove from array
* @return array with identical contents excluding values of `value`
*/ // TODO
public static String[] removeValue(String[] array, String valueToRemove) {
return null;
}

/**
* @param array array of chars
* @return array of Strings with consecutive duplicates removes
*/ // TODO
public static String[] removeConsecutiveDuplicates(String[] array) {
return null;
}

/**
* @param array array of chars
* @return array of Strings with each consecutive duplicate occurrence concatenated as a single string in an array of Strings
*/ // TODO
public static String[] packConsecutiveDuplicates(String[] array) {
return null;
}


}
Loading

0 comments on commit 28c0c30

Please sign in to comment.