Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ZhangJiayu0303
Copy link

Update the User Guide; Add a new command findPhoneNumber to find a person's information through input his telephone number.

@ZhangJiayu0303 ZhangJiayu0303 changed the title [W5][W16-2]Zhang Jiayu [W5][W16-3]Zhang Jiayu Feb 12, 2019
@FanDongzhe
Copy link

It's really a good job to find a person by some other details.

Copy link

@ronghualui ronghualui left a 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());

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+"));

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.*;

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

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.

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.

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.

4 participants