From 3060d8d9ebf37fbe83cf8595d320b1afc90e0903 Mon Sep 17 00:00:00 2001 From: Sheikh-Umar Date: Sun, 4 Mar 2018 22:15:25 +0800 Subject: [PATCH 01/33] I updated the user guide to reflect the sort command. --- doc/UserGuide.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/UserGuide.md b/doc/UserGuide.md index d03dfce73..652c227c4 100644 --- a/doc/UserGuide.md +++ b/doc/UserGuide.md @@ -100,6 +100,10 @@ Examples: Clears all entries from the address book.
Format: `clear` +## Sorting all entries: `sort` +Sorts all entries in the address book in increasing alphabetical order based on the first name.
+Format: `sort` + ## Exiting the program : `exit` Exits the program.
Format: `exit` From f7fc7d3dce42afea10ee0955245881cd6b3fafc3 Mon Sep 17 00:00:00 2001 From: Sheikh-Umar Date: Sun, 4 Mar 2018 22:17:14 +0800 Subject: [PATCH 02/33] I updated the help command by adding in the sort command. --- src/seedu/addressbook/commands/HelpCommand.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/seedu/addressbook/commands/HelpCommand.java b/src/seedu/addressbook/commands/HelpCommand.java index ef2ed7d0e..d8e64b2da 100644 --- a/src/seedu/addressbook/commands/HelpCommand.java +++ b/src/seedu/addressbook/commands/HelpCommand.java @@ -20,6 +20,7 @@ public class HelpCommand extends Command { + "\n" + ViewAllCommand.MESSAGE_USAGE + "\n" + HelpCommand.MESSAGE_USAGE + "\n" + ExitCommand.MESSAGE_USAGE; + + "\n" + SortCommand.MESSAGE_USAGE @Override public CommandResult execute() { From 5a4c737b85d764735736234c3c73f46b65464014 Mon Sep 17 00:00:00 2001 From: Sheikh-Umar Date: Sun, 4 Mar 2018 22:28:33 +0800 Subject: [PATCH 03/33] I added a sort command. --- .../addressbook/commands/SortCommand.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/seedu/addressbook/commands/SortCommand.java diff --git a/src/seedu/addressbook/commands/SortCommand.java b/src/seedu/addressbook/commands/SortCommand.java new file mode 100644 index 000000000..b76f9fbed --- /dev/null +++ b/src/seedu/addressbook/commands/SortCommand.java @@ -0,0 +1,25 @@ +package seedu.addressbook.commands; + +import seedu.addressbook.data.person.Person; + +import java.util.List; + +/** + * Lists all persons in the address book in a sorted order based on the first name of the person + */ +public class SortCommand extends Command { + + public static final String COMMAND_WORD = "sort"; + + public static final String MESSAGE_USAGE = COMMAND_WORD + ":\n" + "Lists all persons in the address book in a sorted order " + + "based on the first name of the person with index numbers.\n\t" + + "Example: " + COMMAND_WORD; + + @Override + public CommandResult execute() { + List allPersons = addressbook.getAllPersons().getInternalList(); + allPersons.sort((Person p1, Person p2) -> (p1.getName().toString()).compareTo(p2.getName().toString())); + return new CommandResult(getMessageForPersonListShownSummary(allPersons), allPersons); + } + +} From 1b1c595db0874205325d451fd182a43e0bf3cd14 Mon Sep 17 00:00:00 2001 From: Sheikh-Umar Date: Sun, 4 Mar 2018 22:33:54 +0800 Subject: [PATCH 04/33] no message --- src/seedu/addressbook/data/person/UniquePersonList.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/seedu/addressbook/data/person/UniquePersonList.java b/src/seedu/addressbook/data/person/UniquePersonList.java index c4848a1b4..988df58ad 100644 --- a/src/seedu/addressbook/data/person/UniquePersonList.java +++ b/src/seedu/addressbook/data/person/UniquePersonList.java @@ -30,6 +30,10 @@ public static class PersonNotFoundException extends Exception {} private final List internalList = new ArrayList<>(); + public List getInternalList() { + return internalList; + } + /** * Constructs empty person list. */ From f3545b95242a862566c4bdb4f711a719cd34d550 Mon Sep 17 00:00:00 2001 From: Sheikh-Umar Date: Sun, 4 Mar 2018 22:44:20 +0800 Subject: [PATCH 05/33] I added a test case for sort command. --- .../seedu/addressbook/logic/LogicTest.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/java/seedu/addressbook/logic/LogicTest.java b/test/java/seedu/addressbook/logic/LogicTest.java index 7efa921ca..09b1794ed 100644 --- a/test/java/seedu/addressbook/logic/LogicTest.java +++ b/test/java/seedu/addressbook/logic/LogicTest.java @@ -201,6 +201,30 @@ public void execute_list_showsAllPersons() throws Exception { expectedList); } + @Test + public void execute_sort_showsAllPerson() throws Exception { + // prepare expectations + TestDataHelper helper = new TestDataHelper(); + Person person1 = helper.generatePersonWithName("John Tan"); + Person person2 = helper.generatePersonWithName("Ali Baba"); + Person person3 = helper.generatePersonWithName("Jill Tan"); + Person person4 = helper.generatePersonWithName("Bob Lee"); + + List expectedList = helper.generatePersonList(person2, person4, person3, person1); + List unorderedList = helper.generatePersonList(person1, person2, person3, person4); + + AddressBook expectedAB = helper.generateAddressBook(unorderedList); + + //prepare address book state + helper.addToAddressBook(addressBook, unorderedList); + assertCommandBehavior("sort", + Command.getMessageForPersonListShownSummary(expectedList), + expectedAB, + true, + expectedList); + + } + @Test public void execute_view_invalidArgsFormat() throws Exception { String expectedMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, ViewCommand.MESSAGE_USAGE); From 8cc0449a9e7b2c4ab9a37280088aa738a3c1fa3e Mon Sep 17 00:00:00 2001 From: Sheikh-Umar Date: Sun, 4 Mar 2018 22:48:02 +0800 Subject: [PATCH 06/33] no message --- src/seedu/addressbook/parser/Parser.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/seedu/addressbook/parser/Parser.java b/src/seedu/addressbook/parser/Parser.java index 58f4f7e6c..07456819c 100644 --- a/src/seedu/addressbook/parser/Parser.java +++ b/src/seedu/addressbook/parser/Parser.java @@ -72,6 +72,9 @@ public Command parseCommand(String userInput) { case ListCommand.COMMAND_WORD: return new ListCommand(); + case SortCommand.COMMAND_WORD: + return new SortCommand(); + case ViewCommand.COMMAND_WORD: return prepareView(arguments); From 8f1c0c0decb014b73af2f443d12a663a04534b67 Mon Sep 17 00:00:00 2001 From: Sheikh-Umar Date: Sun, 4 Mar 2018 22:55:35 +0800 Subject: [PATCH 07/33] I updated the Sort Command message based on feedback from Travis. --- src/seedu/addressbook/commands/HelpCommand.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/seedu/addressbook/commands/HelpCommand.java b/src/seedu/addressbook/commands/HelpCommand.java index d8e64b2da..02313e136 100644 --- a/src/seedu/addressbook/commands/HelpCommand.java +++ b/src/seedu/addressbook/commands/HelpCommand.java @@ -19,8 +19,8 @@ public class HelpCommand extends Command { + "\n" + ViewCommand.MESSAGE_USAGE + "\n" + ViewAllCommand.MESSAGE_USAGE + "\n" + HelpCommand.MESSAGE_USAGE - + "\n" + ExitCommand.MESSAGE_USAGE; - + "\n" + SortCommand.MESSAGE_USAGE + + "\n" + ExitCommand.MESSAGE_USAGE + + "\n" + SortCommand.MESSAGE_USAGE; @Override public CommandResult execute() { From 0d1333773e2925d55305481658e31de6b55456d6 Mon Sep 17 00:00:00 2001 From: Sheikh-Umar Date: Sun, 4 Mar 2018 23:05:10 +0800 Subject: [PATCH 08/33] Updated UniquePersonList based on feedback from Travis. --- src/seedu/addressbook/data/person/UniquePersonList.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/seedu/addressbook/data/person/UniquePersonList.java b/src/seedu/addressbook/data/person/UniquePersonList.java index 988df58ad..a144d6a77 100644 --- a/src/seedu/addressbook/data/person/UniquePersonList.java +++ b/src/seedu/addressbook/data/person/UniquePersonList.java @@ -30,7 +30,7 @@ public static class PersonNotFoundException extends Exception {} private final List internalList = new ArrayList<>(); - public List getInternalList() { + public List getInternalList() { return internalList; } From 7f8742be071bc9cbc29c4179394f37085c69d972 Mon Sep 17 00:00:00 2001 From: Sheikh-Umar Date: Sun, 4 Mar 2018 23:12:30 +0800 Subject: [PATCH 09/33] I corrected a typo error. --- src/seedu/addressbook/commands/SortCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/seedu/addressbook/commands/SortCommand.java b/src/seedu/addressbook/commands/SortCommand.java index b76f9fbed..ce0d50efd 100644 --- a/src/seedu/addressbook/commands/SortCommand.java +++ b/src/seedu/addressbook/commands/SortCommand.java @@ -17,7 +17,7 @@ public class SortCommand extends Command { @Override public CommandResult execute() { - List allPersons = addressbook.getAllPersons().getInternalList(); + List allPersons = addressBook.getAllPersons().getInternalList(); allPersons.sort((Person p1, Person p2) -> (p1.getName().toString()).compareTo(p2.getName().toString())); return new CommandResult(getMessageForPersonListShownSummary(allPersons), allPersons); } From f50cf242dfcff75ba4887bb6f39d4eeb664cf605 Mon Sep 17 00:00:00 2001 From: Sheikh-Umar Date: Mon, 5 Mar 2018 09:49:24 +0800 Subject: [PATCH 10/33] I updated the user command for the edit command. --- doc/UserGuide.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/doc/UserGuide.md b/doc/UserGuide.md index 652c227c4..e55723499 100644 --- a/doc/UserGuide.md +++ b/doc/UserGuide.md @@ -66,6 +66,24 @@ Examples: `delete 1`
Deletes the 1st person in the results of the `find` command. +## Editing a person: `edit` +Edits a particular attribute of a person in the address book. Irreversible.
+Format: `edit INDEX ATTRIBUTE NEW_VALUE` + +> Edits the person at the specified `INDEX` by replacing the `ATTRIBUTE` of the person with the `NEW_VALUE`. + The index refers to the index number shown in the most recent listing. + +> If an invalid `ATTRIBUTE` is entered or the `NEW_VALUE` that is entered is identical + to the current value of the `ATTRIBUTE`, there will be no changes to be made. + + Examples: +* `list`
+ `edit 2 phone 90091234`
+ Edits the 2nd person in the address book by updating his/her phone number to "90091234". + `list`
+ `edit 1 name Jake`
+ Edits the 1st person in the address book by updating his/her name to "Jake". + ## View non-private details of a person : `view` Displays the non-private details of the specified person.
Format: `view INDEX` From 01997fbb9cc84e3001f759e45f88246896ef17ce Mon Sep 17 00:00:00 2001 From: Sheikh-Umar Date: Mon, 5 Mar 2018 10:51:38 +0800 Subject: [PATCH 11/33] I updated the EditCommand, HelpCommand, Messages, and Parser java files. --- .../addressbook/commands/EditCommand.java | 106 ++++++++++++++++++ .../addressbook/commands/HelpCommand.java | 1 + src/seedu/addressbook/common/Messages.java | 2 + src/seedu/addressbook/parser/Parser.java | 44 +++++++- 4 files changed, 152 insertions(+), 1 deletion(-) create mode 100644 src/seedu/addressbook/commands/EditCommand.java diff --git a/src/seedu/addressbook/commands/EditCommand.java b/src/seedu/addressbook/commands/EditCommand.java new file mode 100644 index 000000000..e13134c5d --- /dev/null +++ b/src/seedu/addressbook/commands/EditCommand.java @@ -0,0 +1,106 @@ +package seedu.addressbook.commands; + +import seedu.addressbook.common.Messages; +import seedu.addressbook.data.exception.IllegalValueException; +import seedu.addressbook.data.person.Address; +import seedu.addressbook.data.person.Email; +import seedu.addressbook.data.person.Name; +import seedu.addressbook.data.person.Person; +import seedu.addressbook.data.person.Phone; +import seedu.addressbook.data.person.ReadOnlyPerson; +import seedu.addressbook.data.person.UniquePersonList.PersonNotFoundException; +import seedu.addressbook.parser.Parser.Attribute; + +/** + * Edits the attribute of the person identified + * based on the last-displayed index of the person in the address book + * by updating his/her atttribute with the new value. + */ +public class EditCommand extends Command { + + public static final String COMMAND_WORD = "edit"; + + public static final String MESSAGE_USAGE = COMMAND_WORD + + ": Edits an attribute of a person identified by an index number " + + "used in the last find/last call.\n" + + "Parameters: INDEX ATTRIBUTE NEW_VALUE\n" + + "Example: " + COMMAND_WORD + "2 name Tom"; + + public static final String MESSAGE_EDIT_PERSON_SUCCESS = "Edit is successful!\n" + + "Original Person: %1$s\n" + + ", Edited Person: %2$s" + + private final Attribute attribute; + + private final String newValue; + + public EditCommand(int targetIndex, Attribute attribute, String newValue) { + super(targetIndex); + this.attribute = attribute; + this.newValue = newValue; + } + + @Override + public CommandResult execute() { + + try { + final ReadOnlyPerson target = getTargetPerson(); + if(isNewValueSameAsOld(target)) { + return new CommandResult(Messages.MESSAGE_INVALID_NEW_VALUE); + } + Person updatedPerson = updateExistingPerson(target); + addressBook.removePerson(target); + addressBook.addPerson(updatedPerson); + return new CommandResult(String.format(MESSAGE_EDIT_PERSON_SUCCESS, + target.getAsTextHidePrivate(), + updatedPerson.getAsTextHidePrivate())); + } catch(IndexOutOfBounds ie) { + return new CommandResult(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); + } catch(PersonNotFoundException pnfe) { + return new CommandResult(Messages.MESSAGE_PERSON_NOT_IN_ADDRESSBOOK); + } catch(IllegalValueException ive) { + return new CommandResult(ive.getMessage()); + } + } + + private boolean isNewValueSameAsOld(ReadOnlyPerson target) { + + switch(attribute) { + case ADDRESS: + return target.getAddress().toString().equals(newValue); + case EMAIL: + return target.getEmail().toString().equals(newValue); + case NAME: + return target.getName().toString().equals(newValue); + case PHONE: + return target.getPhone().toString().equals(newValue); + default: + return true; + } + } + + private Person updateExistingPerson(ReadOnlyPerson existingPerson) throws IllegalValueException { + Address address = existingPerson.getAddress(); + Email email = existingPerson.getEmail(); + Name name = existingPerson.getName(); + Phone phone = existingPerson.getPhone(); + + switch(attribute) { + case ADDRESS: + address = new Address(newValue, address.isPrivate()); + break; + case EMAIL: + email = new Email(newValue, email.isPrivate()); + break; + case NAME: + name = new Name(newValue); + break; + case PHONE: + name = new Phone(newValue, phone.isPrivate()); + break; + } + + return new Person(name, phone, email, address, existingPerson.getTags()); + } + +} \ No newline at end of file diff --git a/src/seedu/addressbook/commands/HelpCommand.java b/src/seedu/addressbook/commands/HelpCommand.java index 02313e136..5da23d77d 100644 --- a/src/seedu/addressbook/commands/HelpCommand.java +++ b/src/seedu/addressbook/commands/HelpCommand.java @@ -14,6 +14,7 @@ public class HelpCommand extends Command { public static final String MESSAGE_ALL_USAGES = AddCommand.MESSAGE_USAGE + "\n" + DeleteCommand.MESSAGE_USAGE + "\n" + ClearCommand.MESSAGE_USAGE + + "\n" + EditCommand.MESSAGE_USAGE + "\n" + FindCommand.MESSAGE_USAGE + "\n" + ListCommand.MESSAGE_USAGE + "\n" + ViewCommand.MESSAGE_USAGE diff --git a/src/seedu/addressbook/common/Messages.java b/src/seedu/addressbook/common/Messages.java index 02cfe6155..5017549e1 100644 --- a/src/seedu/addressbook/common/Messages.java +++ b/src/seedu/addressbook/common/Messages.java @@ -8,6 +8,8 @@ public class Messages { public static final String MESSAGE_INVALID_COMMAND_FORMAT = "Invalid command format! \n%1$s"; public static final String MESSAGE_INVALID_PERSON_DISPLAYED_INDEX = "The person index provided is invalid"; public static final String MESSAGE_PERSON_NOT_IN_ADDRESSBOOK = "Person could not be found in address book"; + public static final String MESSAGE_INVALID_ATTRIBUTE = "Invalid attribute entered"; + public static final String MESSAGE_INVALID_NEW_VALUE = "Invalid new value entered as it is the same as the old value"; public static final String MESSAGE_PERSONS_LISTED_OVERVIEW = "%1$d persons listed!"; public static final String MESSAGE_PROGRAM_LAUNCH_ARGS_USAGE = "Launch command format: " + "java seedu.addressbook.Main [STORAGE_FILE_PATH]"; diff --git a/src/seedu/addressbook/parser/Parser.java b/src/seedu/addressbook/parser/Parser.java index 07456819c..81c713978 100644 --- a/src/seedu/addressbook/parser/Parser.java +++ b/src/seedu/addressbook/parser/Parser.java @@ -7,7 +7,9 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import static seedu.addressbook.common.Messages.MESSAGE_INVALID_ATTRIBUTE; import static seedu.addressbook.common.Messages.MESSAGE_INVALID_COMMAND_FORMAT; +import static seedu.addressbook.common.Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX; /** * Parses user input. @@ -16,6 +18,11 @@ public class Parser { public static final Pattern PERSON_INDEX_ARGS_FORMAT = Pattern.compile("(?.+)"); + public static final Pattern EDIT_PERSON_ARGS_FORMAT = + Pattern.compile("(?\\S+)" + + " (?\\S+)" + + " (?\\S+)"); + + public static final Pattern KEYWORDS_ARGS_FORMAT = Pattern.compile("(?\\S+(?:\\s+\\S+)*)"); // one or more keywords separated by whitespace @@ -63,6 +70,9 @@ public Command parseCommand(String userInput) { case DeleteCommand.COMMAND_WORD: return prepareDelete(arguments); + case EditCommand.COMMAND_WORD: + return prepareEdit(arguments); + case ClearCommand.COMMAND_WORD: return new ClearCommand(); @@ -143,7 +153,6 @@ private static Set getTagsFromArgs(String tagArguments) throws IllegalVa return new HashSet<>(tagStrings); } - /** * Parses arguments in the context of the delete person command. * @@ -151,6 +160,7 @@ private static Set getTagsFromArgs(String tagArguments) throws IllegalVa * @return the prepared command */ private Command prepareDelete(String args) { + try { final int targetIndex = parseArgsAsDisplayedIndex(args); return new DeleteCommand(targetIndex); @@ -229,5 +239,37 @@ private Command prepareFind(String args) { return new FindCommand(keywordSet); } + /** + * Parses arguments in the context of the editing person command. + * + * @param args full command args string + * @return the prepared command + */ + private Command prepareEdit(String args) { + final Matcher matcher = KEYWORDS_ARGS_FORMAT.matcher(args.trim()); + // Validate arg string format + if (!matcher.matches()) { + return new IncorrectCommand(String.format(MESSAGE_INVALID_COMMAND_FORMAT, + EditCommand.MESSAGE_USAGE)); + } + try { + String originalTargetIndex = matcher.group("targetIndex").trim(); + String originalAttribute = matcher.group("attribute").trim(); + final int targetIndex = parseArgsAsDisplayedIndex(originalTargetIndex); + final Attribute attribute = Attribute.valueOf(rawAttribute.toUpperCase()); + final String newValue = matcher.group("newValue").trim(); + return new EditCommand(targetIndex, attribute, newValue); + } catch (ParseException pe) { + return new IncorrectCommand(String.format(MESSAGE_INVALID_COMMAND_FORMAT, + EditCommand(MESSAGE_USAGE)); + } catch (NumberFormatException nfe) { + return new IncorrectCommand(MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); + } catch (IllegalArgumentException iae) { + return new IncorrectCommand(MESSAGE_INVALID_ATTRIBUTE); + } + } + public enum Attribute { + NAME, PHONE, EMAIL, ADDRESS + } } \ No newline at end of file From a8d5b7e0d11e7cc68e3cd78759c72871778b1985 Mon Sep 17 00:00:00 2001 From: Sheikh-Umar Date: Mon, 5 Mar 2018 11:02:54 +0800 Subject: [PATCH 12/33] I updated the code based on feedback from Travis. --- src/seedu/addressbook/commands/EditCommand.java | 2 +- src/seedu/addressbook/parser/Parser.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/seedu/addressbook/commands/EditCommand.java b/src/seedu/addressbook/commands/EditCommand.java index e13134c5d..4d3544fde 100644 --- a/src/seedu/addressbook/commands/EditCommand.java +++ b/src/seedu/addressbook/commands/EditCommand.java @@ -28,7 +28,7 @@ public class EditCommand extends Command { public static final String MESSAGE_EDIT_PERSON_SUCCESS = "Edit is successful!\n" + "Original Person: %1$s\n" - + ", Edited Person: %2$s" + + ", Edited Person: %2$s"; private final Attribute attribute; diff --git a/src/seedu/addressbook/parser/Parser.java b/src/seedu/addressbook/parser/Parser.java index 81c713978..886304595 100644 --- a/src/seedu/addressbook/parser/Parser.java +++ b/src/seedu/addressbook/parser/Parser.java @@ -22,7 +22,7 @@ public class Parser { Pattern.compile("(?\\S+)" + " (?\\S+)" + " (?\\S+)"); - + + public static final Pattern KEYWORDS_ARGS_FORMAT = Pattern.compile("(?\\S+(?:\\s+\\S+)*)"); // one or more keywords separated by whitespace @@ -261,7 +261,7 @@ private Command prepareEdit(String args) { return new EditCommand(targetIndex, attribute, newValue); } catch (ParseException pe) { return new IncorrectCommand(String.format(MESSAGE_INVALID_COMMAND_FORMAT, - EditCommand(MESSAGE_USAGE)); + EditCommand.MESSAGE_USAGE)); } catch (NumberFormatException nfe) { return new IncorrectCommand(MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); } catch (IllegalArgumentException iae) { From 68db7a308f58bb5b5830fc552ba9d37c8fa7f82d Mon Sep 17 00:00:00 2001 From: Sheikh-Umar Date: Mon, 5 Mar 2018 11:11:59 +0800 Subject: [PATCH 13/33] I made changes to the EditCommand and Parser java files based on feedback from Travis. --- src/seedu/addressbook/commands/EditCommand.java | 4 ++-- src/seedu/addressbook/parser/Parser.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/seedu/addressbook/commands/EditCommand.java b/src/seedu/addressbook/commands/EditCommand.java index 4d3544fde..b4ace6854 100644 --- a/src/seedu/addressbook/commands/EditCommand.java +++ b/src/seedu/addressbook/commands/EditCommand.java @@ -54,7 +54,7 @@ public CommandResult execute() { return new CommandResult(String.format(MESSAGE_EDIT_PERSON_SUCCESS, target.getAsTextHidePrivate(), updatedPerson.getAsTextHidePrivate())); - } catch(IndexOutOfBounds ie) { + } catch(IndexOutOfBoundsException ie) { return new CommandResult(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); } catch(PersonNotFoundException pnfe) { return new CommandResult(Messages.MESSAGE_PERSON_NOT_IN_ADDRESSBOOK); @@ -96,7 +96,7 @@ private Person updateExistingPerson(ReadOnlyPerson existingPerson) throws Illega name = new Name(newValue); break; case PHONE: - name = new Phone(newValue, phone.isPrivate()); + phone = new Phone(newValue, phone.isPrivate()); break; } diff --git a/src/seedu/addressbook/parser/Parser.java b/src/seedu/addressbook/parser/Parser.java index 886304595..2ac5429cb 100644 --- a/src/seedu/addressbook/parser/Parser.java +++ b/src/seedu/addressbook/parser/Parser.java @@ -256,7 +256,7 @@ private Command prepareEdit(String args) { String originalTargetIndex = matcher.group("targetIndex").trim(); String originalAttribute = matcher.group("attribute").trim(); final int targetIndex = parseArgsAsDisplayedIndex(originalTargetIndex); - final Attribute attribute = Attribute.valueOf(rawAttribute.toUpperCase()); + final Attribute attribute = Attribute.valueOf(originalAttribute.toUpperCase()); final String newValue = matcher.group("newValue").trim(); return new EditCommand(targetIndex, attribute, newValue); } catch (ParseException pe) { From 29188e07215f5b71563c67cecb9e17114956d3fe Mon Sep 17 00:00:00 2001 From: Sheikh-Umar Date: Mon, 5 Mar 2018 16:33:02 +0800 Subject: [PATCH 14/33] I stated the sources that I referred to for these particular java files. --- src/seedu/addressbook/commands/EditCommand.java | 2 ++ src/seedu/addressbook/parser/Parser.java | 1 + 2 files changed, 3 insertions(+) diff --git a/src/seedu/addressbook/commands/EditCommand.java b/src/seedu/addressbook/commands/EditCommand.java index b4ace6854..202afdb14 100644 --- a/src/seedu/addressbook/commands/EditCommand.java +++ b/src/seedu/addressbook/commands/EditCommand.java @@ -16,6 +16,8 @@ * based on the last-displayed index of the person in the address book * by updating his/her atttribute with the new value. */ + +//Solution below adapted from https://github.com/nus-cs2103-AY1718S2/addressbook-level3/pull/749/files public class EditCommand extends Command { public static final String COMMAND_WORD = "edit"; diff --git a/src/seedu/addressbook/parser/Parser.java b/src/seedu/addressbook/parser/Parser.java index 2ac5429cb..86b72f866 100644 --- a/src/seedu/addressbook/parser/Parser.java +++ b/src/seedu/addressbook/parser/Parser.java @@ -14,6 +14,7 @@ /** * Parses user input. */ +//Solution below adapted from https://github.com/nus-cs2103-AY1718S2/addressbook-level3/pull/749/files public class Parser { public static final Pattern PERSON_INDEX_ARGS_FORMAT = Pattern.compile("(?.+)"); From 40208eeae39461e4ae6f972b5e338534ba6b896c Mon Sep 17 00:00:00 2001 From: Sheikh-Umar Date: Mon, 5 Mar 2018 20:33:30 +0800 Subject: [PATCH 15/33] no message --- src/seedu/addressbook/parser/Parser.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/seedu/addressbook/parser/Parser.java b/src/seedu/addressbook/parser/Parser.java index 86b72f866..e6c26c2f2 100644 --- a/src/seedu/addressbook/parser/Parser.java +++ b/src/seedu/addressbook/parser/Parser.java @@ -273,4 +273,5 @@ private Command prepareEdit(String args) { public enum Attribute { NAME, PHONE, EMAIL, ADDRESS } + } \ No newline at end of file From 733224c2af8a3cb14490f6c0bf4ebfbfd8da5b14 Mon Sep 17 00:00:00 2001 From: Sheikh-Umar Date: Mon, 5 Mar 2018 20:47:09 +0800 Subject: [PATCH 16/33] I updated the find command of the User Guide. --- doc/UserGuide.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/UserGuide.md b/doc/UserGuide.md index e55723499..3de9d9c5b 100644 --- a/doc/UserGuide.md +++ b/doc/UserGuide.md @@ -42,12 +42,12 @@ Format: `list` Finds persons whose names contain any of the 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 not case sensitive, 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` and `john` * `find Betsy Tim John`
Returns Any person having names `Betsy`, `Tim`, or `John` From 1d6df7b2d8cf9a5a8a763fc0d842591260793acf Mon Sep 17 00:00:00 2001 From: Sheikh-Umar Date: Mon, 5 Mar 2018 20:51:47 +0800 Subject: [PATCH 17/33] Revert "I updated the find command of the User Guide." This reverts commit 733224c2af8a3cb14490f6c0bf4ebfbfd8da5b14. --- doc/UserGuide.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/UserGuide.md b/doc/UserGuide.md index 3de9d9c5b..e55723499 100644 --- a/doc/UserGuide.md +++ b/doc/UserGuide.md @@ -42,12 +42,12 @@ Format: `list` Finds persons whose names contain any of the given keywords.
Format: `find KEYWORD [MORE_KEYWORDS]` -> The search is not case sensitive, the order of the keywords does not matter, only the name is searched, +> The search is case sensitive, 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` and `john` + Returns `John Doe` but not `john` * `find Betsy Tim John`
Returns Any person having names `Betsy`, `Tim`, or `John` From e14d3826b0c703f61fe7d1741620a5f070b28920 Mon Sep 17 00:00:00 2001 From: Sheikh-Umar Date: Mon, 5 Mar 2018 21:04:09 +0800 Subject: [PATCH 18/33] Added a test case to StorageFileTest.java --- test/java/seedu/addressbook/storage/StorageFileTest.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/java/seedu/addressbook/storage/StorageFileTest.java b/test/java/seedu/addressbook/storage/StorageFileTest.java index 1bd6fcab3..c42cdc417 100644 --- a/test/java/seedu/addressbook/storage/StorageFileTest.java +++ b/test/java/seedu/addressbook/storage/StorageFileTest.java @@ -104,6 +104,11 @@ private AddressBook getTestAddressBook() throws Exception { new Email("betsycrowe@gmail.com", false), new Address("Newgate Prison", true), new UniqueTagList(new Tag("friend"), new Tag("criminal")))); + ab.addPerson(new Person(new Name("john tan"), + new Phone("90001234", false), + new Email("johntan@gmail.com", false), + new Address("Baker street, block 999, #05-09", false), + new UniqueTagList(Collections.emptySet()))); return ab; } } From 9f7cb53806a4d3b9253a6c43380c687d5b3a90c3 Mon Sep 17 00:00:00 2001 From: Sheikh-Umar Date: Mon, 5 Mar 2018 21:10:18 +0800 Subject: [PATCH 19/33] no message --- src/seedu/addressbook/parser/Parser.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/seedu/addressbook/parser/Parser.java b/src/seedu/addressbook/parser/Parser.java index 86b72f866..e6c26c2f2 100644 --- a/src/seedu/addressbook/parser/Parser.java +++ b/src/seedu/addressbook/parser/Parser.java @@ -273,4 +273,5 @@ private Command prepareEdit(String args) { public enum Attribute { NAME, PHONE, EMAIL, ADDRESS } + } \ No newline at end of file From 8ba31f17049dd96bf7fadffb83beb5557a89ab52 Mon Sep 17 00:00:00 2001 From: Sheikh-Umar Date: Mon, 5 Mar 2018 21:12:56 +0800 Subject: [PATCH 20/33] I updated the StorageFileTest.java. --- test/java/seedu/addressbook/storage/StorageFileTest.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/test/java/seedu/addressbook/storage/StorageFileTest.java b/test/java/seedu/addressbook/storage/StorageFileTest.java index c42cdc417..1bd6fcab3 100644 --- a/test/java/seedu/addressbook/storage/StorageFileTest.java +++ b/test/java/seedu/addressbook/storage/StorageFileTest.java @@ -104,11 +104,6 @@ private AddressBook getTestAddressBook() throws Exception { new Email("betsycrowe@gmail.com", false), new Address("Newgate Prison", true), new UniqueTagList(new Tag("friend"), new Tag("criminal")))); - ab.addPerson(new Person(new Name("john tan"), - new Phone("90001234", false), - new Email("johntan@gmail.com", false), - new Address("Baker street, block 999, #05-09", false), - new UniqueTagList(Collections.emptySet()))); return ab; } } From b96dc5c5de81f4eeb5b856090d4b3540f8ca1c05 Mon Sep 17 00:00:00 2001 From: Sheikh-Umar Date: Mon, 5 Mar 2018 21:18:01 +0800 Subject: [PATCH 21/33] I updated the add command to make the name entered to lowercase. --- src/seedu/addressbook/commands/AddCommand.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/seedu/addressbook/commands/AddCommand.java b/src/seedu/addressbook/commands/AddCommand.java index b0f202d42..34914a2f6 100644 --- a/src/seedu/addressbook/commands/AddCommand.java +++ b/src/seedu/addressbook/commands/AddCommand.java @@ -31,7 +31,7 @@ public class AddCommand extends Command { * * @throws IllegalValueException if any of the raw values are invalid */ - public AddCommand(String name, + public AddCommand(String name.toLowerCase(), String phone, boolean isPhonePrivate, String email, boolean isEmailPrivate, String address, boolean isAddressPrivate, @@ -41,7 +41,7 @@ public AddCommand(String name, tagSet.add(new Tag(tagName)); } this.toAdd = new Person( - new Name(name), + new Name(name.toLowerCase()), new Phone(phone, isPhonePrivate), new Email(email, isEmailPrivate), new Address(address, isAddressPrivate), From 1b67d4da0dde14f698ce7417c4fb3269b92d559e Mon Sep 17 00:00:00 2001 From: Sheikh-Umar Date: Mon, 5 Mar 2018 21:20:55 +0800 Subject: [PATCH 22/33] Revert "I updated the add command to make the name entered to lowercase." This reverts commit b96dc5c5de81f4eeb5b856090d4b3540f8ca1c05. --- src/seedu/addressbook/commands/AddCommand.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/seedu/addressbook/commands/AddCommand.java b/src/seedu/addressbook/commands/AddCommand.java index 34914a2f6..b0f202d42 100644 --- a/src/seedu/addressbook/commands/AddCommand.java +++ b/src/seedu/addressbook/commands/AddCommand.java @@ -31,7 +31,7 @@ public class AddCommand extends Command { * * @throws IllegalValueException if any of the raw values are invalid */ - public AddCommand(String name.toLowerCase(), + public AddCommand(String name, String phone, boolean isPhonePrivate, String email, boolean isEmailPrivate, String address, boolean isAddressPrivate, @@ -41,7 +41,7 @@ public AddCommand(String name.toLowerCase(), tagSet.add(new Tag(tagName)); } this.toAdd = new Person( - new Name(name.toLowerCase()), + new Name(name), new Phone(phone, isPhonePrivate), new Email(email, isEmailPrivate), new Address(address, isAddressPrivate), From ee9d207fbdb09ed020ef692578d4fdded22cf6c1 Mon Sep 17 00:00:00 2001 From: Sheikh-Umar Date: Mon, 5 Mar 2018 21:24:03 +0800 Subject: [PATCH 23/33] no message --- src/seedu/addressbook/commands/AddCommand.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/seedu/addressbook/commands/AddCommand.java b/src/seedu/addressbook/commands/AddCommand.java index b0f202d42..a579016cb 100644 --- a/src/seedu/addressbook/commands/AddCommand.java +++ b/src/seedu/addressbook/commands/AddCommand.java @@ -66,5 +66,4 @@ public CommandResult execute() { return new CommandResult(MESSAGE_DUPLICATE_PERSON); } } - } From db1d746efbebe39ee0ad9aa64628091100968305 Mon Sep 17 00:00:00 2001 From: Sheikh-Umar Date: Mon, 5 Mar 2018 21:27:36 +0800 Subject: [PATCH 24/33] no message --- src/seedu/addressbook/commands/AddCommand.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/seedu/addressbook/commands/AddCommand.java b/src/seedu/addressbook/commands/AddCommand.java index a579016cb..b0f202d42 100644 --- a/src/seedu/addressbook/commands/AddCommand.java +++ b/src/seedu/addressbook/commands/AddCommand.java @@ -66,4 +66,5 @@ public CommandResult execute() { return new CommandResult(MESSAGE_DUPLICATE_PERSON); } } + } From 81c8d722778def30d7cc192a3a7a43da16bd25c5 Mon Sep 17 00:00:00 2001 From: Sheikh-Umar Date: Mon, 5 Mar 2018 21:39:27 +0800 Subject: [PATCH 25/33] Converts name to lowercase. --- src/seedu/addressbook/data/person/Name.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/seedu/addressbook/data/person/Name.java b/src/seedu/addressbook/data/person/Name.java index 487b7ad9c..77d015ee9 100644 --- a/src/seedu/addressbook/data/person/Name.java +++ b/src/seedu/addressbook/data/person/Name.java @@ -23,11 +23,11 @@ public class Name { * @throws IllegalValueException if given name string is invalid. */ public Name(String name) throws IllegalValueException { - name = name.trim(); + name = name.toLowerCase().trim(); if (!isValidName(name)) { throw new IllegalValueException(MESSAGE_NAME_CONSTRAINTS); } - this.fullName = name; + this.fullName = name.toLowerCase(); } /** @@ -41,12 +41,12 @@ public static boolean isValidName(String test) { * Retrieves a listing of every word in the name, in order. */ public List getWordsInName() { - return Arrays.asList(fullName.split("\\s+")); + return Arrays.asList(fullName.toLowerCase().split("\\s+")); } @Override public String toString() { - return fullName; + return fullName.toLowerCase(); } @Override From ecf7c7ce71dd9c404c0bef9e6e872a202b35c8d9 Mon Sep 17 00:00:00 2001 From: Sheikh-Umar Date: Mon, 5 Mar 2018 21:44:13 +0800 Subject: [PATCH 26/33] no message --- src/seedu/addressbook/data/person/Name.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/seedu/addressbook/data/person/Name.java b/src/seedu/addressbook/data/person/Name.java index 77d015ee9..487b7ad9c 100644 --- a/src/seedu/addressbook/data/person/Name.java +++ b/src/seedu/addressbook/data/person/Name.java @@ -23,11 +23,11 @@ public class Name { * @throws IllegalValueException if given name string is invalid. */ public Name(String name) throws IllegalValueException { - name = name.toLowerCase().trim(); + name = name.trim(); if (!isValidName(name)) { throw new IllegalValueException(MESSAGE_NAME_CONSTRAINTS); } - this.fullName = name.toLowerCase(); + this.fullName = name; } /** @@ -41,12 +41,12 @@ public static boolean isValidName(String test) { * Retrieves a listing of every word in the name, in order. */ public List getWordsInName() { - return Arrays.asList(fullName.toLowerCase().split("\\s+")); + return Arrays.asList(fullName.split("\\s+")); } @Override public String toString() { - return fullName.toLowerCase(); + return fullName; } @Override From b54df6c7c053ab42b81023c2b4130908450367fd Mon Sep 17 00:00:00 2001 From: Sheikh-Umar Date: Thu, 8 Mar 2018 21:16:07 +0800 Subject: [PATCH 27/33] Updated User Guide, Name & Parser documents for making add and find commands case-insensitive. --- doc/UserGuide.md | 3 ++- src/seedu/addressbook/commands/FindCommand.java | 4 ++-- src/seedu/addressbook/data/person/Name.java | 8 ++++---- src/seedu/addressbook/parser/Parser.java | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/doc/UserGuide.md b/doc/UserGuide.md index d03dfce73..1ec9ba5b1 100644 --- a/doc/UserGuide.md +++ b/doc/UserGuide.md @@ -20,6 +20,7 @@ Format: `help` ## Adding a person: `add` Adds a person to the address book
+Name of person added to address book is stored in lowercase
Format: `add NAME [p]p/PHONE_NUMBER [p]e/EMAIL [p]a/ADDRESS [t/TAG]...` > Words in `UPPER_CASE` are the parameters, items in `SQUARE_BRACKETS` are optional, @@ -42,7 +43,7 @@ Format: `list` Finds persons whose names contain any of the 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 not case sensitive, 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: diff --git a/src/seedu/addressbook/commands/FindCommand.java b/src/seedu/addressbook/commands/FindCommand.java index c8e9a380f..61494c7e6 100644 --- a/src/seedu/addressbook/commands/FindCommand.java +++ b/src/seedu/addressbook/commands/FindCommand.java @@ -20,7 +20,7 @@ public class FindCommand extends Command { private final Set keywords; public FindCommand(Set keywords) { - this.keywords = keywords; + this.keywords = keywords.toLowerCase(); } /** @@ -45,7 +45,7 @@ public CommandResult execute() { private List getPersonsWithNameContainingAnyKeyword(Set keywords) { final List matchedPersons = new ArrayList<>(); for (ReadOnlyPerson person : addressBook.getAllPersons()) { - final Set wordsInName = new HashSet<>(person.getName().getWordsInName()); + final Set wordsInName = new HashSet<>(person.getName().getWordsInName().toLowerCase()); if (!Collections.disjoint(wordsInName, keywords)) { matchedPersons.add(person); } diff --git a/src/seedu/addressbook/data/person/Name.java b/src/seedu/addressbook/data/person/Name.java index 487b7ad9c..734cfdf29 100644 --- a/src/seedu/addressbook/data/person/Name.java +++ b/src/seedu/addressbook/data/person/Name.java @@ -23,7 +23,7 @@ public class Name { * @throws IllegalValueException if given name string is invalid. */ public Name(String name) throws IllegalValueException { - name = name.trim(); + name = name.toLowerCase().trim(); if (!isValidName(name)) { throw new IllegalValueException(MESSAGE_NAME_CONSTRAINTS); } @@ -41,19 +41,19 @@ public static boolean isValidName(String test) { * Retrieves a listing of every word in the name, in order. */ public List getWordsInName() { - return Arrays.asList(fullName.split("\\s+")); + return Arrays.asList(fullName.toLowerCase().split("\\s+")); } @Override public String toString() { - return fullName; + return fullName.toLowerCase(); } @Override public boolean equals(Object other) { return other == this // short circuit if same object || (other instanceof Name // instanceof handles nulls - && this.fullName.equals(((Name) other).fullName)); // state check + && this.fullName.toLowerCase().equals(((Name) other).fullName.toLowerCase())); // state check } @Override diff --git a/src/seedu/addressbook/parser/Parser.java b/src/seedu/addressbook/parser/Parser.java index 58f4f7e6c..091898f76 100644 --- a/src/seedu/addressbook/parser/Parser.java +++ b/src/seedu/addressbook/parser/Parser.java @@ -214,7 +214,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)); From 7edfb2a510e37bee0a3d0a45374370fd109d6bb5 Mon Sep 17 00:00:00 2001 From: Sheikh-Umar Date: Thu, 8 Mar 2018 21:19:23 +0800 Subject: [PATCH 28/33] no message --- src/seedu/addressbook/commands/AddCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/seedu/addressbook/commands/AddCommand.java b/src/seedu/addressbook/commands/AddCommand.java index b0f202d42..68f1eab85 100644 --- a/src/seedu/addressbook/commands/AddCommand.java +++ b/src/seedu/addressbook/commands/AddCommand.java @@ -9,7 +9,7 @@ import java.util.Set; /** - * Adds a person to the address book. + * Adds a person to the address book.. */ public class AddCommand extends Command { From fa1ed450f840979c5a7e72e63ed4902423490b66 Mon Sep 17 00:00:00 2001 From: Sheikh-Umar Date: Thu, 8 Mar 2018 21:34:18 +0800 Subject: [PATCH 29/33] Updated FindCommand and AddCommand. --- doc/UserGuide.md | 3 +-- src/seedu/addressbook/commands/AddCommand.java | 2 +- src/seedu/addressbook/commands/FindCommand.java | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/doc/UserGuide.md b/doc/UserGuide.md index df79438cf..e55723499 100644 --- a/doc/UserGuide.md +++ b/doc/UserGuide.md @@ -20,7 +20,6 @@ Format: `help` ## Adding a person: `add` Adds a person to the address book
-Name of person added to address book is stored in lowercase
Format: `add NAME [p]p/PHONE_NUMBER [p]e/EMAIL [p]a/ADDRESS [t/TAG]...` > Words in `UPPER_CASE` are the parameters, items in `SQUARE_BRACKETS` are optional, @@ -43,7 +42,7 @@ Format: `list` Finds persons whose names contain any of the given keywords.
Format: `find KEYWORD [MORE_KEYWORDS]` -> The search is not case sensitive, the order of the keywords does not matter, only the name is searched, +> The search is case sensitive, 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: diff --git a/src/seedu/addressbook/commands/AddCommand.java b/src/seedu/addressbook/commands/AddCommand.java index 68f1eab85..b0f202d42 100644 --- a/src/seedu/addressbook/commands/AddCommand.java +++ b/src/seedu/addressbook/commands/AddCommand.java @@ -9,7 +9,7 @@ import java.util.Set; /** - * Adds a person to the address book.. + * Adds a person to the address book. */ public class AddCommand extends Command { diff --git a/src/seedu/addressbook/commands/FindCommand.java b/src/seedu/addressbook/commands/FindCommand.java index 61494c7e6..c8e9a380f 100644 --- a/src/seedu/addressbook/commands/FindCommand.java +++ b/src/seedu/addressbook/commands/FindCommand.java @@ -20,7 +20,7 @@ public class FindCommand extends Command { private final Set keywords; public FindCommand(Set keywords) { - this.keywords = keywords.toLowerCase(); + this.keywords = keywords; } /** @@ -45,7 +45,7 @@ public CommandResult execute() { private List getPersonsWithNameContainingAnyKeyword(Set keywords) { final List matchedPersons = new ArrayList<>(); for (ReadOnlyPerson person : addressBook.getAllPersons()) { - final Set wordsInName = new HashSet<>(person.getName().getWordsInName().toLowerCase()); + final Set wordsInName = new HashSet<>(person.getName().getWordsInName()); if (!Collections.disjoint(wordsInName, keywords)) { matchedPersons.add(person); } From 339a1ec70fe7de67c4424cf74d7b77303b8248fa Mon Sep 17 00:00:00 2001 From: Sheikh-Umar Date: Thu, 8 Mar 2018 22:12:48 +0800 Subject: [PATCH 30/33] Updated Clear Command. --- src/seedu/addressbook/commands/ClearCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/seedu/addressbook/commands/ClearCommand.java b/src/seedu/addressbook/commands/ClearCommand.java index 330146aaa..e7dee18d9 100644 --- a/src/seedu/addressbook/commands/ClearCommand.java +++ b/src/seedu/addressbook/commands/ClearCommand.java @@ -1,7 +1,7 @@ package seedu.addressbook.commands; /** - * Clears the address book. + * Clears all persons from the address book. */ public class ClearCommand extends Command { From 98b9723bd70c66db4e8774ba57cb29e9a1601b31 Mon Sep 17 00:00:00 2001 From: Sheikh-Umar Date: Thu, 8 Mar 2018 22:16:20 +0800 Subject: [PATCH 31/33] Updated Name java document. --- src/seedu/addressbook/data/person/Name.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/seedu/addressbook/data/person/Name.java b/src/seedu/addressbook/data/person/Name.java index 734cfdf29..bfda03b42 100644 --- a/src/seedu/addressbook/data/person/Name.java +++ b/src/seedu/addressbook/data/person/Name.java @@ -41,19 +41,19 @@ public static boolean isValidName(String test) { * Retrieves a listing of every word in the name, in order. */ public List getWordsInName() { - return Arrays.asList(fullName.toLowerCase().split("\\s+")); + return Arrays.asList(fullName.split("\\s+")); } @Override public String toString() { - return fullName.toLowerCase(); + return fullName; } @Override public boolean equals(Object other) { return other == this // short circuit if same object || (other instanceof Name // instanceof handles nulls - && this.fullName.toLowerCase().equals(((Name) other).fullName.toLowerCase())); // state check + && this.fullName.equals(((Name) other).fullName.)); // state check } @Override From 2052e3098038c55de092482f058f71385a866e59 Mon Sep 17 00:00:00 2001 From: Sheikh-Umar Date: Thu, 8 Mar 2018 22:22:54 +0800 Subject: [PATCH 32/33] Updated Name java document. --- src/seedu/addressbook/data/person/Name.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/seedu/addressbook/data/person/Name.java b/src/seedu/addressbook/data/person/Name.java index bfda03b42..29827065f 100644 --- a/src/seedu/addressbook/data/person/Name.java +++ b/src/seedu/addressbook/data/person/Name.java @@ -18,12 +18,12 @@ public class Name { public final String fullName; /** - * Validates given name. + * Validates the given name. * * @throws IllegalValueException if given name string is invalid. */ public Name(String name) throws IllegalValueException { - name = name.toLowerCase().trim(); + name = name.trim(); if (!isValidName(name)) { throw new IllegalValueException(MESSAGE_NAME_CONSTRAINTS); } @@ -53,7 +53,7 @@ public String toString() { public boolean equals(Object other) { return other == this // short circuit if same object || (other instanceof Name // instanceof handles nulls - && this.fullName.equals(((Name) other).fullName.)); // state check + && this.fullName.equals(((Name) other).fullName)); // state check } @Override From 4c5a231a6c1a7b194ea9184726c0bda35b442f82 Mon Sep 17 00:00:00 2001 From: Sheikh-Umar Date: Thu, 8 Mar 2018 22:58:36 +0800 Subject: [PATCH 33/33] Updated ClearCommand. --- src/seedu/addressbook/commands/ClearCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/seedu/addressbook/commands/ClearCommand.java b/src/seedu/addressbook/commands/ClearCommand.java index e7dee18d9..330146aaa 100644 --- a/src/seedu/addressbook/commands/ClearCommand.java +++ b/src/seedu/addressbook/commands/ClearCommand.java @@ -1,7 +1,7 @@ package seedu.addressbook.commands; /** - * Clears all persons from the address book. + * Clears the address book. */ public class ClearCommand extends Command {