-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add Find Address #77
Add Find Address #77
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
|
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.
Good job Harith! Keep it up!
@Test | ||
public void parseCommand_findAddress() throws Exception { | ||
List<String> keywords = Arrays.asList("Tampines", "Street", "1"); | ||
FindAddressCommand command = (FindAddressCommand) parser.parseCommand( | ||
FindAddressCommand.COMMAND_WORD + " " + keywords.stream().collect(Collectors.joining(" "))); | ||
assertEquals(new FindAddressCommand(new AddressContainsKeywordsPredicate(keywords)), command); | ||
} | ||
|
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.
Good addition of test cases!
@Override | ||
public boolean test(Person person) { | ||
// Check if any of the keywords match any part of the address | ||
return keywords.stream() | ||
.anyMatch(keywords -> person.getAddress().value.toLowerCase().contains(keywords.toLowerCase())); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
if (other == this) { | ||
return true; | ||
} | ||
|
||
// instanceof handles nulls | ||
if (!(other instanceof AddressContainsKeywordsPredicate)) { | ||
return false; | ||
} | ||
|
||
AddressContainsKeywordsPredicate otherAddressContainsKeywordsPredicate = | ||
(AddressContainsKeywordsPredicate) other; | ||
return keywords.equals(otherAddressContainsKeywordsPredicate.keywords); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return new ToStringBuilder(this).add("keywords", keywords).toString(); | ||
} | ||
} |
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.
Nicely formatted and arranged code!
@@ -8,7 +8,7 @@ | |||
import seedu.address.model.person.NameContainsKeywordsPredicate; | |||
|
|||
/** | |||
* Finds and lists all persons in address book whose name contains any of the argument keywords. | |||
* Finds and lists all persons in ClientHub whose name contains any of the argument keywords. |
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.
Good change!
Things Done
close #65