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.7][F10-1]Raynard Hadiwidjaja #449

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/UserGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ and persons matching at least one keyword will be returned (i.e. `OR` search).
Examples:

* `find John` +
Returns `John Doe` but not `john`.
Returns `John Doe` and `john`.

* `find Betsy Tim John` +
Returns Any person having names `Betsy`, `Tim`, or `John`.
Returns Any person having names `Betsy`, `betsy`, `Tim`, `tim`, `John` and `john`.

== Deleting a person : `delete`

Expand Down
2 changes: 1 addition & 1 deletion src/seedu/addressbook/data/person/Name.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static boolean isValidName(String test) {
* Retrieves a listing of every word in the name, in order.
*/
public List<String> getWordsInName() {
return Arrays.asList(fullName.split("\\s+"));
return Arrays.asList(fullName.toLowerCase().split("\\s+"));
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/seedu/addressbook/parser/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ private int parseArgsAsDisplayedIndex(String args) throws ParseException, Number
* @return the prepared command
*/
private Command prepareFind(String args) {
final Matcher matcher = KEYWORDS_ARGS_FORMAT.matcher(args.trim());
final Matcher matcher = KEYWORDS_ARGS_FORMAT.matcher(args.toLowerCase().trim());
if (!matcher.matches()) {
return new IncorrectCommand(String.format(MESSAGE_INVALID_COMMAND_FORMAT,
FindCommand.MESSAGE_USAGE));
Expand Down
3 changes: 2 additions & 1 deletion test/expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,9 @@
|| 0 persons listed!
|| ===================================================
|| Enter command: || [Command entered: find betsy]
|| 1. Betsy Choo Tags: [secretive]
||
|| 0 persons listed!
|| 1 persons listed!
|| ===================================================
|| Enter command: || [Command entered: find Betsy]
|| 1. Betsy Choo Tags: [secretive]
Expand Down
6 changes: 5 additions & 1 deletion test/java/seedu/addressbook/commands/FindCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void execute() throws IllegalValueException {
assertFindCommandBehavior(new String[]{"Amy"}, Arrays.asList(td.amy));

//same word, different case: not matched
assertFindCommandBehavior(new String[]{"aMy"}, Collections.emptyList());
assertFindCommandBehavior(new String[]{"aMy"}, Arrays.asList(td.amy));

//partial word: not matched
assertFindCommandBehavior(new String[]{"my"}, Collections.emptyList());
Expand Down Expand Up @@ -54,6 +54,10 @@ private void assertFindCommandBehavior(String[] keywords, List<ReadOnlyPerson> e
}

private FindCommand createFindCommand(String[] keywords) {
// Change all the keyword to lowercase.
for(int i = 0; i < keywords.length; i++){
keywords[i] = keywords[i].toLowerCase();
}
final Set<String> keywordSet = new HashSet<>(Arrays.asList(keywords));
FindCommand command = new FindCommand(keywordSet);
command.setData(addressBook, Collections.emptyList());
Expand Down