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.11][T12-3] Davindran #165

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
16 changes: 13 additions & 3 deletions docs/UserGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,17 @@ Format: `find KEYWORD [MORE_KEYWORDS]`

[NOTE]
====
The search is case sensitive, the order of the keywords does not matter, only the name is searched,
The search is NOT case sensitive, the order of the keywords does not matter, only the name is searched,

Choose a reason for hiding this comment

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

good job updating docs! 👍

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` or `john`.

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

== Deleting a person : `delete`

Expand Down Expand Up @@ -176,10 +176,20 @@ Example:

* `java seedu.addressbook.Main mydata.txt`

== ENHANCEMENT

Choose a reason for hiding this comment

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

Don't have to add this if you've mentioned it above in the find command description (:

The 'find' function is not case sensitive!

Examples:

* `find john` +
Returns `John Doe` or `john doe`.


[NOTE]
====
The file name must end in `.txt` for it to be acceptable to the program.

When running the program inside IntelliJ, you can set command line parameters
before running the program.
====

3 changes: 2 additions & 1 deletion src/seedu/addressbook/commands/FindCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
/**
* Finds and lists all persons in address book whose name contains any of the argument keywords.
* Keyword matching is case sensitive.
* ENHANCEMENT: keyword matching is NOT case sensitive.

Choose a reason for hiding this comment

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

good job updating comments

*/
public class FindCommand extends Command {

public static final String COMMAND_WORD = "find";

public static final String MESSAGE_USAGE = COMMAND_WORD + ": Finds all persons whose names contain any of "
+ "the specified keywords (case-sensitive) and displays them as a list with index numbers.\n"
+ "the specified keywords (non case-sensitive) and displays them as a list with index numbers.\n"
+ "Parameters: KEYWORD [MORE_KEYWORDS]...\n"
+ "Example: " + COMMAND_WORD + " alice bob charlie";

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.toUpperCase().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 @@ -238,7 +238,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.toUpperCase().trim());

Choose a reason for hiding this comment

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

good (:

if (!matcher.matches()) {
return new IncorrectCommand(String.format(MESSAGE_INVALID_COMMAND_FORMAT,
FindCommand.MESSAGE_USAGE));
Expand Down
9 changes: 5 additions & 4 deletions test/expected.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
|| 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 contain any of the specified keywords (NON case-sensitive) and displays them as a list with index numbers.

Choose a reason for hiding this comment

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

good job updating tests (:

|| Parameters: KEYWORD [MORE_KEYWORDS]...
|| Example: find alice bob charlie
|| list: Displays all persons in the address book as a list with index numbers.
Expand Down Expand Up @@ -200,7 +200,7 @@
|| ===================================================
|| 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 contain any of the specified keywords (NON case-sensitive) and displays them as a list with index numbers.
|| Parameters: KEYWORD [MORE_KEYWORDS]...
|| Example: find alice bob charlie
|| ===================================================
Expand All @@ -213,8 +213,9 @@
|| 0 persons listed!
|| ===================================================
|| Enter command: || [Command entered: find betsy]
||
|| 0 persons listed!
|| 1. Betsy Choo Tags: [secretive]
||
|| 1 persons listed!
|| ===================================================
|| Enter command: || [Command entered: find Betsy]
|| 1. Betsy Choo Tags: [secretive]
Expand Down
2 changes: 1 addition & 1 deletion test/input.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
find bet
# does not match if none have keyword
find 23912039120
# matching should be case-sensitive
# matching should not be case-sensitive
find betsy

# find unique keyword
Expand Down