Skip to content

Replace StringManipulation.java and StringManipulationTest.java with …#24

Open
michael-degroot wants to merge 1 commit intomainfrom
Michael_deGroot_CodeReview
Open

Replace StringManipulation.java and StringManipulationTest.java with …#24
michael-degroot wants to merge 1 commit intomainfrom
Michael_deGroot_CodeReview

Conversation

@michael-degroot
Copy link

…my versions.

@michael-degroot michael-degroot requested review from NadavH12, SilverSynch and kaimmej and removed request for NadavH12, SilverSynch and kaimmej June 16, 2023 06:57
@sarafarag sarafarag requested a review from karninskuel June 16, 2023 23:43
@Override
public void setString(String string) {
}
public void setString(String string) { manipulatedstring = string;}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I have noted that your data member for the string in question is "manipulatedstring" this is a good name and place to begin

if (manipulatedstring == "") {
return wordCount;
}
String trimmedString = manipulatedstring.trim();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like trim is a popular tool for this method implementation, looks good to me at the moment.

}
}
}
String finalString = String.copyValueOf(newCharArray);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good organization to copy things over to one final string.

return null;
}
public String restoreString(int[] indices){
char[] initCharArray = manipulatedstring.toCharArray();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prominent use of toCharArray, clever tool for solving these kinds of string character counting sort of problems.

public void testRemoveNthCharacter4() {
fail("Not yet implemented");
manipulatedstring.setString("Hello World is such an overused phrase:)");
assertEquals("Hello Wor d is such an overus d phrase: ", manipulatedstring.removeNthCharacter(10, true));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like multiples of 10, good work, good idea to test for bigger jumps.

public void testRemoveNthCharacter6() {
fail("Not yet implemented");
manipulatedstring.setString("Hello World");
assertEquals(" ", manipulatedstring.removeNthCharacter(1, true));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a smart test to make, no issues, just seeing if retains the space that we told it to keep.

int [] array;
array=new int[]{6,7,8,9,10,5,0,1,2,3,4};
String restoreString = manipulatedstring.restoreString(array);
assertEquals(restoreString, "World Hello");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a correct rearrangement. There isn't really anything I would change about your test cases.

fail("Not yet implemented");
manipulatedstring.setString("Hello, World");
String [] sStings = manipulatedstring.getSubStrings(1, 2);
assertEquals(sStings[0], "Hello" );

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work checking the shorter strings. Making sure to test all kinds of cases is important.

Copy link

@karninskuel karninskuel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The overall test cases and class implementations looked very solid. There is not a lot to my eyes that I would advise changing. The class implementations seemed effective and all the test cases seemed to follow along and match the outcomes of every method. Overall, good work.

@michael-degroot
Copy link
Author

Karan,
Thanks for the detailed review and feedback -- much appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants