diff --git a/src/main/java/seedu/address/logic/commands/ClearCommand.java b/src/main/java/seedu/address/logic/commands/ClearCommand.java index f63c551b157..2f09bb29450 100644 --- a/src/main/java/seedu/address/logic/commands/ClearCommand.java +++ b/src/main/java/seedu/address/logic/commands/ClearCommand.java @@ -18,6 +18,7 @@ public class ClearCommand extends Command { public CommandResult execute(Model model) { requireNonNull(model); model.setAddressBook(new AddressBook()); + model.clearPersonDetails(); return new CommandResult(MESSAGE_SUCCESS); } } diff --git a/src/main/java/seedu/address/model/Model.java b/src/main/java/seedu/address/model/Model.java index 6f2710b2304..015088f0fb1 100644 --- a/src/main/java/seedu/address/model/Model.java +++ b/src/main/java/seedu/address/model/Model.java @@ -103,6 +103,11 @@ public interface Model { */ void showPersonAtIndex(Index index); + /** + * CLears details of person displayed in detail view of UI. + */ + void clearPersonDetails(); + /** Returns an unmodifiable view of the filtered person list */ ObservableList getFilteredPersonList(); diff --git a/src/main/java/seedu/address/model/ModelManager.java b/src/main/java/seedu/address/model/ModelManager.java index 9a7566cda5b..d61656edabc 100644 --- a/src/main/java/seedu/address/model/ModelManager.java +++ b/src/main/java/seedu/address/model/ModelManager.java @@ -111,6 +111,11 @@ public void showPersonAtIndex(Index index) { } } + @Override + public void clearPersonDetails() { + currentPerson.set(Optional.empty()); + } + @Override public void deletePerson(Person target) { addressBook.removePerson(target); diff --git a/src/test/java/seedu/address/logic/commands/AddCommandTest.java b/src/test/java/seedu/address/logic/commands/AddCommandTest.java index c5af906a2ee..82dd74415f8 100644 --- a/src/test/java/seedu/address/logic/commands/AddCommandTest.java +++ b/src/test/java/seedu/address/logic/commands/AddCommandTest.java @@ -157,6 +157,11 @@ public void showPersonAtIndex(Index index) { throw new AssertionError("This method should not be called."); } + @Override + public void clearPersonDetails() { + throw new AssertionError("This method should not be called."); + } + @Override public ObservableList getFilteredPersonList() { throw new AssertionError("This method should not be called.");