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][W09-B2] Kevin Chin #954

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
68 changes: 68 additions & 0 deletions src/seedu/addressbook/data/tag/Tagging.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package seedu.addressbook.data.tag;

import java.util.Objects;

import seedu.addressbook.data.person.Person;

/**
* Represents the adding or deleting of a tag for a specific person that happened during a session
*/
public class Tagging {

private static final String ADD_TAGGING = "+";
private static final String DELETE_TAGGING = "-";

public enum ActionType {
ADD, DELETE;
}

private Person person;
private Tag tag;
private ActionType actionType;

public Tagging(Person person, Tag tag, ActionType actionType) {
this.person = person;
this.tag = tag;
this.actionType = actionType;
}

public Person getPerson() {
return person;
}

public Tag getTag() {
return tag;
}

public ActionType getActionType() {
return actionType;
}

@Override
public boolean equals(Object obj) {
return obj == this // short circuit if same object
|| obj instanceof Tagging // instanceof handles null
&& ((Tagging) obj).getPerson().equals(this.person)
&& ((Tagging) obj).getTag().equals(this.tag)
&& ((Tagging) obj).getActionType().equals(this.getActionType());
}

@Override
public int hashCode() {
return Objects.hash(person, tag, actionType);
}

@Override
public String toString() {
String actionType;

if (this.actionType == ActionType.ADD){
actionType = ADD_TAGGING;
}else{
actionType = DELETE_TAGGING;
}

return actionType + " " + person.getName() + " [" + tag + "]";
}
}