celine_chiou updated skeleton with my code for peer review#17
celine_chiou updated skeleton with my code for peer review#17
Conversation
KhalilxCoats
left a comment
There was a problem hiding this comment.
The code is functional, neat, and efficient. One of the test cases could be a bit more thorough in checking for exceptions, but overall there don't seem to be any major issues.
|
|
||
| public class StringManipulation implements StringManipulationInterface { | ||
| private String currentString; | ||
| private int count; |
There was a problem hiding this comment.
given that the word count value is only used when called by the count() function, would it not be better to have count be local to the count function as opposed to to having it as a private data member.
| String trimmedString = currentString.trim().replaceAll("\\s+", " "); | ||
| String[] wordArray = trimmedString.split(" "); | ||
|
|
||
| // throws IndexOutOfBoundsException If the string has less than "endWord" words in it |
There was a problem hiding this comment.
It could be neater if you placed this code with the other exception if-statement so all the code that handles exceptions for this method are in one place, maybe even as an else-if statement as opposed to a completely separate if-statement.
| @Test | ||
| public void testGeSubStrings2() { | ||
| fail("Not yet implemented"); | ||
| manipulatedstring.setString("This is my test string sentence that should only return a few words"); |
There was a problem hiding this comment.
Somewhat redundant test case since it does the same thing as the first test.
| public void testGeSubStrings4() { | ||
| fail("Not yet implemented"); | ||
| manipulatedstring.setString("This is my test string"); | ||
| assertThrows(IllegalArgumentException.class, () -> { |
There was a problem hiding this comment.
Is there any way to ensure that this test case is throwing the illegal argument exception in response to the negative number argument and not because the start word is greater than the end word, given that both throw the same exception type.
No description provided.