updated the skeleton project with my complete project.#20
updated the skeleton project with my complete project.#20pnarasimhan2021 wants to merge 2 commits intomainfrom
Conversation
aravindrsripada
left a comment
There was a problem hiding this comment.
Hi Priyanka! Your code looks great. I added some feedback which really just show alternate ways to do what your code does. Keep up the good work!
| } | ||
|
|
||
| String result = new String(); | ||
| result = result.concat(str.charAt(0) + ""); |
There was a problem hiding this comment.
This portion of the for loop in the removeNthCharacter() method seems to have some redundant code. Is there an advantage to starting your for loop at index = 1?
| return 0; | ||
| } | ||
|
|
||
| String[] splitStr = str.split("\\s+"); |
There was a problem hiding this comment.
I really like how you used the split method with regex to get the appropriate count of words. I will definitely be implementing this into my own code. Thank you
| result = result.concat(str.charAt(0) + ""); | ||
| for (int i = 1; i < str.length(); i++) { | ||
| if((i+1) % n != 0) { | ||
| result = result.concat(str.charAt(i) + ""); |
There was a problem hiding this comment.
This is personal preference but I like using += when concatenating strings together. Personally I think that nesting methods inside one another makes code harder to read.
| public void testRemoveNthCharacter5() { | ||
| fail("Not yet implemented"); | ||
| manipulatedstring.setString("I'd b3tt3r put s0me d161ts in this 5tr1n6, right?"); | ||
| Throwable exception = assertThrows(IndexOutOfBoundsException.class, () -> manipulatedstring.removeNthCharacter(100, false)); |
There was a problem hiding this comment.
I believe you can use the assertThrows() method without having to set it equal to a Throwable object. The assertThrow() method checks to see whether the method you provided in the lambda function returns the same Throwable as the Throwable you claim it will throw. Your way of checking definitely works.
No description provided.