Skip to content

Add previous implementation#25

Open
ulyfm wants to merge 1 commit intomainfrom
Ulysses_Foote-McNabb_CodeReview
Open

Add previous implementation#25
ulyfm wants to merge 1 commit intomainfrom
Ulysses_Foote-McNabb_CodeReview

Conversation

@ulyfm
Copy link

@ulyfm ulyfm commented Jun 16, 2023

No description provided.

Copy link

@BladeTheHunter005 BladeTheHunter005 left a comment

Choose a reason for hiding this comment

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

Project accepted. Code review successfully completed

@@ -1,32 +1,79 @@
public class StringManipulation implements StringManipulationInterface {
private String myString = "";

Choose a reason for hiding this comment

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

Great job creating the StringManipulation class and implementing the StringManipulation Interface.

public String getString() {
return null;
return myString;
}

Choose a reason for hiding this comment

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

It's good to see the getString() method implemented, which returns the value of myString. It allows users to retrieve the current string.

@Override
public void setString(String string) {
myString = string;
}

Choose a reason for hiding this comment

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

Method effectively sets the value of myString to the provided string.

}
}
return i;
}

Choose a reason for hiding this comment

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

Have you considered using the enhanced for-loop syntax for the count() method to improve readability? For example,
for(String str: spl) instead of using traditional for-loop.

To make the code even more readable, could you add a comment explaining what the purpose of the count() method is?
I know we all know what it is and what it does, but good practice is documenting everything.

}
}
return ret.toString();
}

Choose a reason for hiding this comment

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

This removeNthCharacter(int n, boolean maintainSpacing) method looks good.
It is good to see you handling cases where n is greater than myString.length() and when n is less than or equal to 0.

Once again have you consider commenting detailed documentation so that your code is easy to modify. Remember in the verification and validation phase of testing that we have to find bugs, ensure readability. Consider documenting everything.

public void testRemoveNthCharacter1() {
manipulatedstring.setString("I'd b3tt3r put s0me d161ts in this 5tr1n6, right?");
assertEquals("I' bttr uts0e 16tsinths trn6 rgh?", manipulatedstring.removeNthCharacter(3, false));
}

Choose a reason for hiding this comment

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

testing the removal of the third character is a good test case.

@@ -87,27 +130,66 @@ public void testGeSubStrings1() {
assertEquals(sStings[1], "string");
}

Choose a reason for hiding this comment

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

you're testing the splitting of a string into substrings. This is a good test case. Have you considered what might happen if the string contains multiple spaces between words?

assertEquals(sStings[0], "my");
assertEquals(sStings[1], "string");
}

Choose a reason for hiding this comment

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

This is a good test case. Have you considered what might happen if the string contains other types of whitespace characters, like tabs or newlines?

* of the spec, but my implementation does it anyway and I wanted to test it.)
*/
@Test
public void testRestoreString5()

Choose a reason for hiding this comment

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

And this one, you're throwing in non-alphanumeric characters into the mix. Real-world strings can be messy and full of all sorts of characters, so it's awesome that you're making sure your method can handle that

* the number of letters in the string.
*/
@Test
public void testRestoreString3()

Choose a reason for hiding this comment

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

Here, you're testing if your method can deal with a mismatch in the number of indices and the number of characters in the string. It's like trying to fit a square peg in a round hole - it's not gonna work, and your method should recognize that. Good on you for checking this!

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