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

[T2A4][W13-A3]Ram Janarthan #298

Open
wants to merge 2 commits 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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ Format: `list`
> Finds persons that match given keywords

Format: `find KEYWORD [MORE_KEYWORDS]`
> The search is case sensitive, the order of the keywords does not matter, only the name is searched,
> The search is case insensitive, the order of the keywords does not matter, only the name is searched,
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`

* `find Betsy Tim John`
> Returns Any person having names `Betsy`, `Tim`, or `John`
Expand Down
9 changes: 8 additions & 1 deletion src/seedu/addressbook/AddressBook.java
Original file line number Diff line number Diff line change
Expand Up @@ -486,13 +486,20 @@ private static ArrayList<String[]> getPersonsWithNameContainingAnyKeyword(Collec
final ArrayList<String[]> matchedPersons = new ArrayList<>();
for (String[] person : getAllPersonsInAddressBook()) {
final Set<String> wordsInName = new HashSet<>(splitByWhitespace(getNameFromPerson(person)));
if (!Collections.disjoint(wordsInName, keywords)) {
if (!Collections.disjoint(toUpperCase(wordsInName), toUpperCase(keywords))) {
matchedPersons.add(person);
}
}
return matchedPersons;
}

private static HashSet<String> toUpperCase(Collection<String> strings) {
Copy link

Choose a reason for hiding this comment

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

Remember to include header comments for such methods

HashSet<String> upperCaseStrings = new HashSet<>();
for (String normalString : strings) {
upperCaseStrings.add(normalString.toUpperCase());
}
return upperCaseStrings;
}
/**
Copy link

Choose a reason for hiding this comment

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

When you modify the behavior, remember to update documentation and tests as well.

* Deletes person identified using last displayed index.
*
Expand Down