- Ensure each of the test cases in the class StringUtils successfully passes upon completion of each of the method stubs in the class StringUtilsTest.
String[] getWords(String sentence)
String getFirstWord(String sentence)
String reverseFirstWord(String sentence)
String reverseFirstWordThenCamelCase(String sentence)
String removeCharacterAtIndex(String str, int index)
- Description
- Given a string containing words delimited by spaces, representative of a sentence, return an array of strings, each element representative of a respective word in the sentence.
-
Sample Script
// Given String inputString = "Once upon a time there was a method"; // When String[] outcome = StringUtils.getWords(inputString); // Then String outcomeStr = Arrays.toString(outcome); System.out.println(outcomeStr);
-
Sample Output
[Once, upon, a, time, there, was, a, method]
- Description
- given a string containing words delimited by spaces, representative of a sentence, return the first word of the sentence
-
Sample Script
// Given String inputString = "Make sure to commit your code"; // When String outcome = StringUtils.getFirstWord(inputString); // Then System.out.println(outcome);
-
Sample Output
Make
- Description
- given a string containing words delimited by spaces, representative of a sentence, return the first word with identical contents in reverse order.
-
Sample Script
// Given String inputString = "Super class sea turtle"; // When String outcome = StringUtils.reverseFirstWord(inputString); // Then System.out.println(outcome);
-
Sample Output
repuS
- Description
- given a string containing words delimited by spaces, representative of a sentence, return the first word with identical contents in reverse order with the first character capitalized.
-
Sample Script
// Given String inputString = "Spoons are for scooping"; // When String actual = StringUtils.reverseFirstWordThenCamelCase(inputString); // Then System.out.println(outcome);
-
Sample Output
Snoops
- Description
- given a string and index, return an identical string excluding the character at the specified index.
-
Sample Script
// Given String inputString = "Goal"; Integer characterIndex = 2; // When String outcome = StringUtils.removeCharacterAtIndex(inputString, characterIndex); // Then System.out.println(outcome);
-
Sample Output
Gol