Skip to content

first commit#16

Open
Hester1937 wants to merge 18 commits intomainfrom
Tong_Liu_CodeReview
Open

first commit#16
Hester1937 wants to merge 18 commits intomainfrom
Tong_Liu_CodeReview

Conversation

@Hester1937
Copy link

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.

Copy link

@jonathanjarman jonathanjarman left a comment

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

Copy link

@jonathanjarman jonathanjarman left a comment

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.

assertThrows(IllegalArgumentException.class, () -> {
int length = manipulatedstring.count();
assertThrows(NullPointerException.class, () -> {
int length = manipulatedstring.count();

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
Author

Choose a reason for hiding this comment

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

I changed already

@@ -167,33 +169,33 @@ public void testRestoreString2() {
manipulatedstring.setString("testing");
int[] indices = {};
String restoredString = manipulatedstring.restoreString(indices);

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
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

for (int i = startWord; i <= endWord; i++) {
substrings[index] = words[i];

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

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
Author

Choose a reason for hiding this comment

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

thank you Jonathan

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