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][T12-1]Sreyans Sipani #170

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

[W5][T12-1]Sreyans Sipani #170

wants to merge 2 commits into from

Conversation

sreycodes
Copy link

No description provided.

@sreycodes
Copy link
Author

Extended Find command for all fields

@nus-se-pr-bot
Copy link

Hi @sreycodes, your pull request title is invalid.

For PR sent as submission of learning a topic/graded exercise, the PR name should be in the format of [Week ID][Team ID] Your Name, where [Week ID] has no dashes or spaces (e.g. [W5]) and [Team ID] has one dash only and no spaces (e.g. [W14-2] means Wednesday 2pm (14 hrs), Team 2).
E.g. If you are in tutorial W09 (i.e. Wednesday 9am), team 1, the PR title would be [W5][W09-1] James Yong. Note that your tutorial IDs are different from those shown in CORS/IVLE.

For team PR, the PR name should be in the format of [Team ID] Product Name (e.g. [T09-2] Contact List Pro).

Please follow the above format strictly and edit your title for reprocessing.

Note: this comment is posted by a bot. If you believe this is done in error, please create an issue at nus-se-pr-bot and add a link to this PR.

@sreycodes sreycodes changed the title Extended Find command for all fields [W5][T12-1]Sreyans Sipani Feb 13, 2019
@sreycodes
Copy link
Author

@Tejas2805, can you help me review this PR?

@ZhangCX10032
Copy link

Very handy improvement. The search command is more powerful now

Copy link

@bqnguyen94 bqnguyen94 left a comment

Choose a reason for hiding this comment

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

This is quite solid work! Just some minor changes needed. Good job! :)

} else {
continue;
}
}

Choose a reason for hiding this comment

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

I think you should utilize guard clauses instead of nested if-else here

@@ -2,6 +2,9 @@

import seedu.addressbook.data.exception.IllegalValueException;

import java.util.Arrays;
import java.util.List;

Choose a reason for hiding this comment

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

I believe these should come before the seedu import :)

*/
public List<String> getKeywordsInAddress() {
return Arrays.asList(value.split("[^a-zA-Z\\d]"));
}

Choose a reason for hiding this comment

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

For consistency with getTagValues perhaps this function should be in FindCommand.java file, or vice versa?

@@ -2,6 +2,9 @@

import seedu.addressbook.data.exception.IllegalValueException;

import java.util.Arrays;
import java.util.List;

Choose a reason for hiding this comment

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

These imports should come before as well

@@ -33,8 +36,13 @@ public Email(String email, boolean isPrivate) throws IllegalValueException {
/**
* Returns true if the given string is a valid person email.
*/
public static boolean isValidEmail(String test) {
return test.matches(EMAIL_VALIDATION_REGEX);
public static boolean isValidEmail(String test) { return test.matches(EMAIL_VALIDATION_REGEX); }

Choose a reason for hiding this comment

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

This change is not related to this PR? Anyway the signature and body of a function should not be on the same line

@@ -32,8 +34,14 @@ public Phone(String phone, boolean isPrivate) throws IllegalValueException {
/**
* Returns true if the given string is a valid person phone number.
*/
public static boolean isValidPhone(String test) {
return test.matches(PHONE_VALIDATION_REGEX);
public static boolean isValidPhone(String test) { return test.matches(PHONE_VALIDATION_REGEX); }

Choose a reason for hiding this comment

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

Unrelated change

public boolean matches(Set<String> keywords) {
for(String keyword: keywords) {
if(isValidPhone(keyword) && value.indexOf(keyword) != -1)
return true;

Choose a reason for hiding this comment

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

This should be wrapped in braces :)

@@ -14,9 +14,9 @@
|| Example: delete 1
|| Clears address book permanently.
|| Example: clear
|| find: Finds all persons whose names contain any of the specified keywords (case-sensitive) and displays them as a list with index numbers.
|| find: Finds all persons whose names, emails, etc. contain any of the specified keywords (alphanumeric and case-sensitive) and displays them as a list withindex numbers.

Choose a reason for hiding this comment

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

withindex is missing a white space :)

@@ -200,9 +200,9 @@
|| ===================================================
|| Enter command: || [Command entered: find]
|| Invalid command format!
|| find: Finds all persons whose names contain any of the specified keywords (case-sensitive) and displays them as a list with index numbers.
|| find: Finds all persons whose names, emails, etc. contain any of the specified keywords (alphanumeric and case-sensitive) and displays them as a list withindex numbers.

Choose a reason for hiding this comment

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

Here as well

|| ===================================================
|| Enter command: || [Command entered: viewall 2]
|| Person could not be found in address book
|| The person index provided is invalid

Choose a reason for hiding this comment

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

Maybe you can update these tests since the added find command made then invalid?

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