-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[W5][W16-3]Zhang Jiayu #146
base: master
Are you sure you want to change the base?
[W5][W16-3]Zhang Jiayu #146
Conversation
It's really a good job to find a person by some other details. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally, good work on the enhancement. There are some violations of the coding standard and some minor issues (refer to comments).
You are encouraged to update your I/O and JUnit tests for your enhancement, to test that your enhancement works.
private List<ReadOnlyPerson> getPersonsWithNameContainingAnyKeyword(Set<String> keywords) { | ||
final List<ReadOnlyPerson> matchedPersons = new ArrayList<>(); | ||
for (ReadOnlyPerson person : addressBook.getAllPersons()) { | ||
final Set<String> wordsInName = new HashSet<>(person.getPhone().getWordsInPhone()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable name does not suit the current operation, since you are retrieving the phone number of a person, not their name (hence wordsInName).
@@ -36,6 +39,10 @@ public static boolean isValidPhone(String test) { | |||
return test.matches(PHONE_VALIDATION_REGEX); | |||
} | |||
|
|||
public List<String> getWordsInPhone() { | |||
return Arrays.asList(value.split("\\s+")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you look at the regex for the phone validation (line 16), the validation will only allow 1 or more digits. Thus, "1234 5678" would have been rejected as a phone number. So, there is no need to split the value by spaces.
It is also recommended for you to change the method name, since there shouldn't be "words" in a phone number.
If you need help in understanding regex, below is an article that may help you:
https://www.vogella.com/tutorials/JavaRegularExpressions/article.html
import seedu.addressbook.commands.ListCommand; | ||
import seedu.addressbook.commands.ViewAllCommand; | ||
import seedu.addressbook.commands.ViewCommand; | ||
import seedu.addressbook.commands.*; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please follow the Java coding standard on the website. You are expected to list all your imported class explicitly. If your IDE is automatically converting this, please do change the settings to prevent it from doing so.
@@ -248,5 +241,18 @@ private Command prepareFind(String args) { | |||
return new FindCommand(keywordSet); | |||
} | |||
|
|||
private Command prepareFindPhoneNumber(String args) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation for this method is missing.
|
||
/** | ||
* Finds and lists all persons in address book whose telephone number is the argument keywords. | ||
* Keyword matching is case sensitive. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment here does not make sense, since case sensitivity are for characters, not numbers.
Update the User Guide; Add a new command findPhoneNumber to find a person's information through input his telephone number.