Skip to content

[W5][T11-2]Li Guanlong - #34

Open
liguanlong wants to merge 4 commits into
nusCS2113-AY1819S2:masterfrom
liguanlong:W5
Open

[W5][T11-2]Li Guanlong#34
liguanlong wants to merge 4 commits into
nusCS2113-AY1819S2:masterfrom
liguanlong:W5

Conversation

@liguanlong

Copy link
Copy Markdown

Added a new command: update, which is used to update an existing contact at the specified index.

@liguanlong liguanlong changed the title [W5][T11-3]Li Guanlong [W5][T11-2]Li Guanlong Feb 10, 2019

@leerachel leerachel 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.

Good job on the new command! Do try to update the test cases too! Please close this PR after reading the comments.

Comment thread docs/UserGuide.adoc

== Updating a person: `update`

Update an existing person in the address book. +

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

"Updates", remember to check for consistency in user guides because it is written by all your teammates, so there needs to be a uniform style of writing for the user guide to appear professional and neat. :)

}
public static final String MESSAGE_UPDATE_PERSON_SUCCESS = "Updated Person: %1$s";
public static final String MESSAGE_DUPLICATE_PERSON = "This person already exists in the address book";
@Override

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Try to add blank lines to your code, it improves readability.

final int targetIndex = parseArgsAsDisplayedIndex(index);
final Matcher matcher = PERSON_DATA_ARGS_FORMAT.matcher(rest.trim());
if (!matcher.matches()) {
return new IncorrectCommand(String.format(MESSAGE_INVALID_COMMAND_FORMAT, AddCommand.MESSAGE_USAGE));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Instead of using AddCommand's MESSAGE_USAGE, maybe try adding a separate "error message" to be more specific in the error handling process so when the system prints out the "message" you will be able to identify which exact part of your code it is running (instead of having the same message appear for 2 different situations).

}
}

private Command prepareUpdate(String args) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing header comment. All non trivial methods should have javadoc format header comments.

@WuPeiHsuan

Copy link
Copy Markdown

Great enhancement! It is a useful command that can be used in our project haha

@shawn-t

shawn-t commented Feb 11, 2019

Copy link
Copy Markdown

Hey Guan Long, interesting enhancement! It saves users from the trouble of first deleting an existing entry and subsequently re-adding him/ her with the updated particulars! Good Job!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants