From a048471fe32c11c30d93110c34755032b2940948 Mon Sep 17 00:00:00 2001 From: olimhc Date: Thu, 15 Mar 2018 02:51:54 +0800 Subject: [PATCH] Add tagging to capture tagging changes in session --- src/seedu/addressbook/Main.java | 3 ++- src/seedu/addressbook/data/AddressBook.java | 11 +++++++++ src/seedu/addressbook/data/Tagging.java | 26 +++++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 src/seedu/addressbook/data/Tagging.java diff --git a/src/seedu/addressbook/Main.java b/src/seedu/addressbook/Main.java index bc18bed7e..1ace5a992 100644 --- a/src/seedu/addressbook/Main.java +++ b/src/seedu/addressbook/Main.java @@ -72,8 +72,9 @@ private void start(String[] launchArgs) { } } - /** Prints the Goodbye message and exits. */ + /** Prints the Tags changes and Goodbye message and exits. */ private void exit() { + addressBook.showTagChanges(); ui.showGoodbyeMessage(); System.exit(0); } diff --git a/src/seedu/addressbook/data/AddressBook.java b/src/seedu/addressbook/data/AddressBook.java index a99a92f9f..59ff34e16 100644 --- a/src/seedu/addressbook/data/AddressBook.java +++ b/src/seedu/addressbook/data/AddressBook.java @@ -12,6 +12,7 @@ import seedu.addressbook.data.person.UniquePersonList.PersonNotFoundException; import seedu.addressbook.data.tag.Tag; import seedu.addressbook.data.tag.UniqueTagList; +import seedu.addressbook.ui.TextUi; /** * Represents the entire address book. Contains the data of the address book. @@ -24,6 +25,8 @@ public class AddressBook { private final UniquePersonList allPersons; private final UniqueTagList allTags; // can contain tags not attached to any person + private Tagging tagging; + private TextUi ui; /** * Creates an empty address book. @@ -31,6 +34,8 @@ public class AddressBook { public AddressBook() { allPersons = new UniquePersonList(); allTags = new UniqueTagList(); + tagging = new Tagging(); + ui = new TextUi(); } /** @@ -121,6 +126,12 @@ public UniqueTagList getAllTags() { return new UniqueTagList(allTags); } + public void showTagChanges(){ + for(String changes : tagging.getTaggingChanges()){ + ui.showToUser(changes); + } + } + @Override public boolean equals(Object other) { return other == this // short circuit if same object diff --git a/src/seedu/addressbook/data/Tagging.java b/src/seedu/addressbook/data/Tagging.java new file mode 100644 index 000000000..554bad77c --- /dev/null +++ b/src/seedu/addressbook/data/Tagging.java @@ -0,0 +1,26 @@ +package seedu.addressbook.data; + +import seedu.addressbook.data.person.Person; +import seedu.addressbook.data.tag.Tag; + +import java.util.ArrayList; + +public class Tagging { + + private static ArrayList tagsChanges = new ArrayList(); + + private final String ADDITION_SYMBOL = "+"; + private final String DELETION_SYMBOL = "-"; + + public void addTags(Person person, Tag tag){ + tagsChanges.add("ADDITION_SYMBOL" + " " + person.getName() + tag.tagName); + } + + public void deleteTags(Person person, Tag tag){ + tagsChanges.add("DELETION_SYMBOL" + " " + person.getName() + tag.tagName); + } + + public ArrayList getTaggingChanges() { + return tagsChanges; + } +}