diff --git a/src/seedu/addressbook/commands/CommandResult.java b/src/seedu/addressbook/commands/CommandResult.java index 8864681c6..43c930b92 100644 --- a/src/seedu/addressbook/commands/CommandResult.java +++ b/src/seedu/addressbook/commands/CommandResult.java @@ -11,7 +11,7 @@ public class CommandResult { /** The feedback message to be shown to the user. Contains a description of the execution result */ - public final String feedbackToUser; + private final String feedbackToUser; /** The list of persons that was produced by the command */ private final List relevantPersons; @@ -33,4 +33,8 @@ public Optional> getRelevantPersons() { return Optional.ofNullable(relevantPersons); } + public String getFeedbackToUser() { + return feedbackToUser; + } + } diff --git a/src/seedu/addressbook/data/tag/Tagging.java b/src/seedu/addressbook/data/tag/Tagging.java new file mode 100644 index 000000000..b4f34afcf --- /dev/null +++ b/src/seedu/addressbook/data/tag/Tagging.java @@ -0,0 +1,34 @@ +package seedu.addressbook.data.tag; + +import java.util.ArrayList; + +import seedu.addressbook.data.person.Person; + +// Association class to that prints out list of all the tags added/deleted during the session + + +public class Tagging { + private ArrayList allTheTags = new ArrayList<>(); + private final String ADD_COMMAND = "add"; + private final String DELETE_COMMAND = "remove"; + + // Record tags added/deleted during that session. + public void trackTagging(String command, Person person, Tag tag) { + if (command.equals(ADD_COMMAND)) { + allTheTags.add("+ " + person.getName().toString() + " " + tag.toString()); + } + else if (command.equals(DELETE_COMMAND)) { + allTheTags.add("- " + person.getName().toString() + " " + tag.toString()); + } + } + + // To print out a list of all the tags added/deleted during the session, when the AddressBook program exits. + public String getAllTags(){ + StringBuilder allActions = new StringBuilder(); + for(String tag: allTheTags){ + allActions.append(tag + "\n"); + } + return allActions.toString(); + } + +} diff --git a/src/seedu/addressbook/ui/TextUi.java b/src/seedu/addressbook/ui/TextUi.java index d30371c70..ad38a528d 100644 --- a/src/seedu/addressbook/ui/TextUi.java +++ b/src/seedu/addressbook/ui/TextUi.java @@ -129,7 +129,7 @@ public void showResultToUser(CommandResult result) { if (resultPersons.isPresent()) { showPersonListView(resultPersons.get()); } - showToUser(result.feedbackToUser, DIVIDER); + showToUser(result.getFeedbackToUser(), DIVIDER); } /** diff --git a/test/java/seedu/addressbook/commands/AddCommandTest.java b/test/java/seedu/addressbook/commands/AddCommandTest.java index fd870a62e..1a630f91a 100644 --- a/test/java/seedu/addressbook/commands/AddCommandTest.java +++ b/test/java/seedu/addressbook/commands/AddCommandTest.java @@ -126,7 +126,7 @@ public void addCommand_emptyAddressBook_addressBookContainsPerson() { assertTrue(people.contains(p)); assertEquals(1, people.immutableListView().size()); assertFalse(result.getRelevantPersons().isPresent()); - assertEquals(String.format(AddCommand.MESSAGE_SUCCESS, p), result.feedbackToUser); + assertEquals(String.format(AddCommand.MESSAGE_SUCCESS, p), result.getFeedbackToUser()); } @Test @@ -139,7 +139,7 @@ public void addCommand_addressBookAlreadyContainsPerson_addressBookUnmodified() CommandResult result = command.execute(); assertFalse(result.getRelevantPersons().isPresent()); - assertEquals(AddCommand.MESSAGE_DUPLICATE_PERSON, result.feedbackToUser); + assertEquals(AddCommand.MESSAGE_DUPLICATE_PERSON, result.getFeedbackToUser()); UniquePersonList people = book.getAllPersons(); assertTrue(people.contains(p)); assertEquals(1, people.immutableListView().size()); diff --git a/test/java/seedu/addressbook/commands/DeleteCommandTest.java b/test/java/seedu/addressbook/commands/DeleteCommandTest.java index 0e5ab80d9..4f71f198d 100644 --- a/test/java/seedu/addressbook/commands/DeleteCommandTest.java +++ b/test/java/seedu/addressbook/commands/DeleteCommandTest.java @@ -109,7 +109,7 @@ private void assertCommandBehaviour(DeleteCommand deleteCommand, String expected CommandResult result = deleteCommand.execute(); - assertEquals(expectedMessage, result.feedbackToUser); + assertEquals(expectedMessage, result.getFeedbackToUser()); assertEquals(expectedAddressBook.getAllPersons(), actualAddressBook.getAllPersons()); } diff --git a/test/java/seedu/addressbook/commands/FindCommandTest.java b/test/java/seedu/addressbook/commands/FindCommandTest.java index f21b1e8e7..1baa0aa12 100644 --- a/test/java/seedu/addressbook/commands/FindCommandTest.java +++ b/test/java/seedu/addressbook/commands/FindCommandTest.java @@ -50,7 +50,7 @@ private void assertFindCommandBehavior(String[] keywords, List e FindCommand command = createFindCommand(keywords); CommandResult result = command.execute(); - assertEquals(Command.getMessageForPersonListShownSummary(expectedPersonList), result.feedbackToUser); + assertEquals(Command.getMessageForPersonListShownSummary(expectedPersonList), result.getFeedbackToUser()); } private FindCommand createFindCommand(String[] keywords) { diff --git a/test/java/seedu/addressbook/commands/ViewCommandTest.java b/test/java/seedu/addressbook/commands/ViewCommandTest.java index 3408463c1..6c1d88161 100644 --- a/test/java/seedu/addressbook/commands/ViewCommandTest.java +++ b/test/java/seedu/addressbook/commands/ViewCommandTest.java @@ -144,7 +144,7 @@ private static void assertViewBehavior(Command viewCommand, AddressBook addressB CommandResult result = viewCommand.execute(); // feedback message is as expected and there are no relevant persons returned. - assertEquals(expectedMessage, result.feedbackToUser); + assertEquals(expectedMessage, result.getFeedbackToUser()); assertEquals(Optional.empty(), result.getRelevantPersons()); // addressbook was not modified.