From 8ee98663684faf8dc90d2f2c3919a0e35b5b45a2 Mon Sep 17 00:00:00 2001 From: Rachel Lee Wang Ling <35750468+leerachel@users.noreply.github.com> Date: Fri, 31 Aug 2018 15:44:36 +0800 Subject: [PATCH 1/4] Update DeveloperGuide.adoc Added user story for "edit" function --- docs/DeveloperGuide.adoc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/DeveloperGuide.adoc b/docs/DeveloperGuide.adoc index 291c4fde9..1b70ffc8f 100644 --- a/docs/DeveloperGuide.adoc +++ b/docs/DeveloperGuide.adoc @@ -43,9 +43,10 @@ Priorities: High (must have) - `* * \*`, Medium (nice to have) - `* \*`, Low (un |=========================================================================================================================================== |Priority |As a ... |I want to ... |So that I can... |`* * *` |new user |see usage instructions |refer to instructions when I forget how to use the App -|`* * *` |user |add a new person | +|`* * *` |user |add a new person | add details of people |`* * *` |user |delete a person |remove entries that I no longer need |`* * *` |user |find a person by name |locate details of persons without having to go through the entire list +|`* * *` |user |edit details of a person |update details or make small changes without having to remove and re-add the person |`* *` |user |hide <> by default |minimize chance of someone else seeing them by accident |`*` |user with many persons in the address book |sort persons by name |locate a person easily |=========================================================================================================================================== From 2a861d6466e2d583afcc03842cd95d27f2c940dc Mon Sep 17 00:00:00 2001 From: leerachel Date: Fri, 21 Sep 2018 02:33:49 +0800 Subject: [PATCH 2/4] Used Polymorphism by adding isMutating() in Command Class --- src/seedu/addressbook/commands/Command.java | 2 ++ src/seedu/addressbook/commands/FindCommand.java | 2 ++ src/seedu/addressbook/commands/HelpCommand.java | 4 ++++ src/seedu/addressbook/commands/IncorrectCommand.java | 3 +++ src/seedu/addressbook/commands/ListCommand.java | 3 +++ src/seedu/addressbook/commands/ViewAllCommand.java | 3 +++ src/seedu/addressbook/commands/ViewCommand.java | 3 +++ src/seedu/addressbook/logic/Logic.java | 6 ++++-- 8 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/seedu/addressbook/commands/Command.java b/src/seedu/addressbook/commands/Command.java index a54cbcb5b..c5c9eee50 100644 --- a/src/seedu/addressbook/commands/Command.java +++ b/src/seedu/addressbook/commands/Command.java @@ -70,4 +70,6 @@ public int getTargetIndex() { public void setTargetIndex(int targetIndex) { this.targetIndex = targetIndex; } + + public boolean isMutating() { return true; } } diff --git a/src/seedu/addressbook/commands/FindCommand.java b/src/seedu/addressbook/commands/FindCommand.java index c8e9a380f..296316e9a 100644 --- a/src/seedu/addressbook/commands/FindCommand.java +++ b/src/seedu/addressbook/commands/FindCommand.java @@ -53,4 +53,6 @@ private List getPersonsWithNameContainingAnyKeyword(Set return matchedPersons; } + @Override + public boolean isMutating() { return false; } } diff --git a/src/seedu/addressbook/commands/HelpCommand.java b/src/seedu/addressbook/commands/HelpCommand.java index ef2ed7d0e..779432dc0 100644 --- a/src/seedu/addressbook/commands/HelpCommand.java +++ b/src/seedu/addressbook/commands/HelpCommand.java @@ -25,4 +25,8 @@ public class HelpCommand extends Command { public CommandResult execute() { return new CommandResult(MESSAGE_ALL_USAGES); } + + @Override + public boolean isMutating() { return false; } + } diff --git a/src/seedu/addressbook/commands/IncorrectCommand.java b/src/seedu/addressbook/commands/IncorrectCommand.java index 81abba7a1..6862a0356 100644 --- a/src/seedu/addressbook/commands/IncorrectCommand.java +++ b/src/seedu/addressbook/commands/IncorrectCommand.java @@ -17,4 +17,7 @@ public CommandResult execute() { return new CommandResult(feedbackToUser); } + @Override + public boolean isMutating() { return false; } + } diff --git a/src/seedu/addressbook/commands/ListCommand.java b/src/seedu/addressbook/commands/ListCommand.java index cb604a8e9..a0caabd99 100644 --- a/src/seedu/addressbook/commands/ListCommand.java +++ b/src/seedu/addressbook/commands/ListCommand.java @@ -22,4 +22,7 @@ public CommandResult execute() { List allPersons = addressBook.getAllPersons().immutableListView(); return new CommandResult(getMessageForPersonListShownSummary(allPersons), allPersons); } + + @Override + public boolean isMutating() { return false; } } diff --git a/src/seedu/addressbook/commands/ViewAllCommand.java b/src/seedu/addressbook/commands/ViewAllCommand.java index ed2c16e83..6b2a33c4c 100644 --- a/src/seedu/addressbook/commands/ViewAllCommand.java +++ b/src/seedu/addressbook/commands/ViewAllCommand.java @@ -37,4 +37,7 @@ public CommandResult execute() { return new CommandResult(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); } } + + @Override + public boolean isMutating() { return false; } } diff --git a/src/seedu/addressbook/commands/ViewCommand.java b/src/seedu/addressbook/commands/ViewCommand.java index 1058c4b52..7e9e6efeb 100644 --- a/src/seedu/addressbook/commands/ViewCommand.java +++ b/src/seedu/addressbook/commands/ViewCommand.java @@ -38,4 +38,7 @@ public CommandResult execute() { } } + @Override + public boolean isMutating() { return false; } + } diff --git a/src/seedu/addressbook/logic/Logic.java b/src/seedu/addressbook/logic/Logic.java index 17afd61a0..c331e586d 100644 --- a/src/seedu/addressbook/logic/Logic.java +++ b/src/seedu/addressbook/logic/Logic.java @@ -76,7 +76,7 @@ public CommandResult execute(String userCommandText) throws Exception { } /** - * Executes the command, updates storage, and returns the result. + * Executes the command, updates storage if data is mutated, and returns the result. * * @param command user command * @return result of the command @@ -85,7 +85,9 @@ public CommandResult execute(String userCommandText) throws Exception { private CommandResult execute(Command command) throws Exception { command.setData(addressBook, lastShownList); CommandResult result = command.execute(); - storage.save(addressBook); + if (command.isMutating() == true) { + storage.save(addressBook); + } return result; } From 38ec2121c291e7eb320f2e0a420fc2e6d706b779 Mon Sep 17 00:00:00 2001 From: leerachel Date: Fri, 21 Sep 2018 02:36:51 +0800 Subject: [PATCH 3/4] Revert "Used Polymorphism by adding isMutating() in Command Class" This reverts commit 2a861d6466e2d583afcc03842cd95d27f2c940dc. --- src/seedu/addressbook/commands/Command.java | 2 -- src/seedu/addressbook/commands/FindCommand.java | 2 -- src/seedu/addressbook/commands/HelpCommand.java | 4 ---- src/seedu/addressbook/commands/IncorrectCommand.java | 3 --- src/seedu/addressbook/commands/ListCommand.java | 3 --- src/seedu/addressbook/commands/ViewAllCommand.java | 3 --- src/seedu/addressbook/commands/ViewCommand.java | 3 --- src/seedu/addressbook/logic/Logic.java | 6 ++---- 8 files changed, 2 insertions(+), 24 deletions(-) diff --git a/src/seedu/addressbook/commands/Command.java b/src/seedu/addressbook/commands/Command.java index c5c9eee50..a54cbcb5b 100644 --- a/src/seedu/addressbook/commands/Command.java +++ b/src/seedu/addressbook/commands/Command.java @@ -70,6 +70,4 @@ public int getTargetIndex() { public void setTargetIndex(int targetIndex) { this.targetIndex = targetIndex; } - - public boolean isMutating() { return true; } } diff --git a/src/seedu/addressbook/commands/FindCommand.java b/src/seedu/addressbook/commands/FindCommand.java index 296316e9a..c8e9a380f 100644 --- a/src/seedu/addressbook/commands/FindCommand.java +++ b/src/seedu/addressbook/commands/FindCommand.java @@ -53,6 +53,4 @@ private List getPersonsWithNameContainingAnyKeyword(Set return matchedPersons; } - @Override - public boolean isMutating() { return false; } } diff --git a/src/seedu/addressbook/commands/HelpCommand.java b/src/seedu/addressbook/commands/HelpCommand.java index 779432dc0..ef2ed7d0e 100644 --- a/src/seedu/addressbook/commands/HelpCommand.java +++ b/src/seedu/addressbook/commands/HelpCommand.java @@ -25,8 +25,4 @@ public class HelpCommand extends Command { public CommandResult execute() { return new CommandResult(MESSAGE_ALL_USAGES); } - - @Override - public boolean isMutating() { return false; } - } diff --git a/src/seedu/addressbook/commands/IncorrectCommand.java b/src/seedu/addressbook/commands/IncorrectCommand.java index 6862a0356..81abba7a1 100644 --- a/src/seedu/addressbook/commands/IncorrectCommand.java +++ b/src/seedu/addressbook/commands/IncorrectCommand.java @@ -17,7 +17,4 @@ public CommandResult execute() { return new CommandResult(feedbackToUser); } - @Override - public boolean isMutating() { return false; } - } diff --git a/src/seedu/addressbook/commands/ListCommand.java b/src/seedu/addressbook/commands/ListCommand.java index a0caabd99..cb604a8e9 100644 --- a/src/seedu/addressbook/commands/ListCommand.java +++ b/src/seedu/addressbook/commands/ListCommand.java @@ -22,7 +22,4 @@ public CommandResult execute() { List allPersons = addressBook.getAllPersons().immutableListView(); return new CommandResult(getMessageForPersonListShownSummary(allPersons), allPersons); } - - @Override - public boolean isMutating() { return false; } } diff --git a/src/seedu/addressbook/commands/ViewAllCommand.java b/src/seedu/addressbook/commands/ViewAllCommand.java index 6b2a33c4c..ed2c16e83 100644 --- a/src/seedu/addressbook/commands/ViewAllCommand.java +++ b/src/seedu/addressbook/commands/ViewAllCommand.java @@ -37,7 +37,4 @@ public CommandResult execute() { return new CommandResult(Messages.MESSAGE_INVALID_PERSON_DISPLAYED_INDEX); } } - - @Override - public boolean isMutating() { return false; } } diff --git a/src/seedu/addressbook/commands/ViewCommand.java b/src/seedu/addressbook/commands/ViewCommand.java index 7e9e6efeb..1058c4b52 100644 --- a/src/seedu/addressbook/commands/ViewCommand.java +++ b/src/seedu/addressbook/commands/ViewCommand.java @@ -38,7 +38,4 @@ public CommandResult execute() { } } - @Override - public boolean isMutating() { return false; } - } diff --git a/src/seedu/addressbook/logic/Logic.java b/src/seedu/addressbook/logic/Logic.java index c331e586d..17afd61a0 100644 --- a/src/seedu/addressbook/logic/Logic.java +++ b/src/seedu/addressbook/logic/Logic.java @@ -76,7 +76,7 @@ public CommandResult execute(String userCommandText) throws Exception { } /** - * Executes the command, updates storage if data is mutated, and returns the result. + * Executes the command, updates storage, and returns the result. * * @param command user command * @return result of the command @@ -85,9 +85,7 @@ public CommandResult execute(String userCommandText) throws Exception { private CommandResult execute(Command command) throws Exception { command.setData(addressBook, lastShownList); CommandResult result = command.execute(); - if (command.isMutating() == true) { - storage.save(addressBook); - } + storage.save(addressBook); return result; } From e92a1c2605db09c8eaf35a36794fbc0fbc047e2a Mon Sep 17 00:00:00 2001 From: leerachel Date: Fri, 21 Sep 2018 02:58:19 +0800 Subject: [PATCH 4/4] Made Command Class's execute() an abstract method --- src/seedu/addressbook/commands/Command.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/seedu/addressbook/commands/Command.java b/src/seedu/addressbook/commands/Command.java index a54cbcb5b..e61829364 100644 --- a/src/seedu/addressbook/commands/Command.java +++ b/src/seedu/addressbook/commands/Command.java @@ -39,9 +39,7 @@ public static String getMessageForPersonListShownSummary(List