From 3c916a22711939c0fa4780ed33bfe0b18008d4d3 Mon Sep 17 00:00:00 2001 From: Nabonita Sen Date: Thu, 9 Nov 2023 22:49:07 +0800 Subject: [PATCH 1/2] Fix bug in Clear Command --- src/main/java/seedu/address/logic/commands/ClearCommand.java | 1 + src/main/java/seedu/address/model/Model.java | 5 +++++ src/main/java/seedu/address/model/ModelManager.java | 5 +++++ 3 files changed, 11 insertions(+) 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); From 60d72f14323ebb4a48585da2aefe080e005d2a64 Mon Sep 17 00:00:00 2001 From: Nabonita Sen Date: Thu, 9 Nov 2023 23:47:00 +0800 Subject: [PATCH 2/2] Update tests --- .../java/seedu/address/logic/commands/AddCommandTest.java | 5 +++++ 1 file changed, 5 insertions(+) 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.");