Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[W8.6b][F11-B2]Lim Hong Cho #965

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/seedu/addressbook/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
11 changes: 11 additions & 0 deletions src/seedu/addressbook/data/AddressBook.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -24,13 +25,17 @@ 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.
*/
public AddressBook() {
allPersons = new UniquePersonList();
allTags = new UniqueTagList();
tagging = new Tagging();
ui = new TextUi();
}

/**
Expand Down Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions src/seedu/addressbook/data/Tagging.java
Original file line number Diff line number Diff line change
@@ -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<String> tagsChanges = new ArrayList<String>();

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<String> getTaggingChanges() {
return tagsChanges;
}
}