Skip to content

first commit#16

Open
Hester1937 wants to merge 18 commits into
mainfrom
Tong_Liu_CodeReview
Open

first commit#16
Hester1937 wants to merge 18 commits into
mainfrom
Tong_Liu_CodeReview

Conversation

@Hester1937

Copy link
Copy Markdown

inclass practise

@sarafarag
sarafarag requested a review from jonathanjarman June 16, 2023 01:38
jonathanjarman

This comment was marked as outdated.

jonathanjarman

This comment was marked as outdated.

@jonathanjarman jonathanjarman left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

In this latest build, you have an extra folder and file. This may be why the build is failing. org/example should be deleted. Then try pushing the commit to see if the build passes.
image

@jonathanjarman jonathanjarman left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This latest commit is very good. I would just try and add some comments to explain what the code is doing. I would also delete the extra Main.java file and org/example folder that are inside of this repo, as it may be why the build is not passing Travis CI. There were some extra local variables that were not being used in some of the test cases, which could be removed. Great job overall though, I noticed throughout the commit history there was steady improvement in the logic and design of the methods.

Comment thread src/main/java/StringManipulation.java
assertThrows(IllegalArgumentException.class, () -> {
int length = manipulatedstring.count();
assertThrows(NullPointerException.class, () -> {
int length = manipulatedstring.count();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

In this method int length is not needed as it won't be used. The second condition for the string is achieve from manipulatedstring.count(). you can remove "int length =" as it is not necessary.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I changed already

Comment thread src/test/java/StringManipulationTest.java Outdated
@@ -167,33 +169,33 @@ public void testRestoreString2() {
manipulatedstring.setString("testing");
int[] indices = {};
String restoredString = manipulatedstring.restoreString(indices);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You can remove the local variable String restoredString as it is not needed since the error will be thrown by the assertThrows. Picture for reference.
image

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I did change here

Comment thread src/test/java/StringManipulationTest.java Outdated
Comment thread src/test/java/StringManipulationTest.java Outdated
Comment thread src/test/java/StringManipulationTest.java Outdated
for (int i = startWord; i <= endWord; i++) {
substrings[index] = words[i];

for (int i = startWord - 1; i < endWord; i++) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

For this method rather than iterating through and copying one word at a time, you can use the arraycopy method to copy the array, which is more efficient. Picture for reference.
image

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

thank you Jonathan

Comment thread src/main/java/org/example/Main.java Outdated
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