From 1553592fb5d7eff1868cbfbc06dd915b94df7bee Mon Sep 17 00:00:00 2001 From: MaggieMeow Date: Fri, 3 Mar 2017 02:17:55 +0800 Subject: [PATCH] Implement DIP for Storage --- .../addressbook/commands/AddCommand.java | 6 +++- src/seedu/addressbook/commands/Command.java | 3 +- src/seedu/addressbook/logic/Logic.java | 7 ++-- src/seedu/addressbook/storage/Storage.java | 32 +++++++++++++++++++ .../addressbook/storage/StorageFile.java | 20 +----------- .../addressbook/storage/StorageFileTest.java | 3 +- 6 files changed, 46 insertions(+), 25 deletions(-) create mode 100644 src/seedu/addressbook/storage/Storage.java diff --git a/src/seedu/addressbook/commands/AddCommand.java b/src/seedu/addressbook/commands/AddCommand.java index b0f202d42..37df6f88e 100644 --- a/src/seedu/addressbook/commands/AddCommand.java +++ b/src/seedu/addressbook/commands/AddCommand.java @@ -56,9 +56,13 @@ public AddCommand(Person toAdd) { public ReadOnlyPerson getPerson() { return toAdd; } + + public boolean isMutating() { + return true; + } @Override - public CommandResult execute() { + public CommandResult execute() throws Exception{ try { addressBook.addPerson(toAdd); return new CommandResult(String.format(MESSAGE_SUCCESS, toAdd)); diff --git a/src/seedu/addressbook/commands/Command.java b/src/seedu/addressbook/commands/Command.java index ccd4fcbf4..dd7aaf5d8 100644 --- a/src/seedu/addressbook/commands/Command.java +++ b/src/seedu/addressbook/commands/Command.java @@ -38,8 +38,9 @@ public static String getMessageForPersonListShownSummary(List