-
Notifications
You must be signed in to change notification settings - Fork 10
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
[T4A2][T01-3] Teo Shu Qi #119
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
package seedu.addressbook.commands; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import seedu.addressbook.data.AddressBook; | ||
import seedu.addressbook.data.person.ReadOnlyPerson; | ||
import seedu.addressbook.data.tag.Tagging; | ||
|
||
/** | ||
* Terminates the program. | ||
*/ | ||
|
@@ -13,10 +20,21 @@ public class ExitCommand extends Command { | |
|
||
@Override | ||
public CommandResult execute() { | ||
printTagging(); | ||
return new CommandResult(MESSAGE_EXIT_ACKNOWEDGEMENT); | ||
} | ||
|
||
public static boolean isExit(Command command) { | ||
return command instanceof ExitCommand; // instanceof returns false if it is null | ||
} | ||
|
||
/** | ||
* Print list of tags added or deleted each person | ||
*/ | ||
public void printTagging() { | ||
ArrayList<Tagging> allTagging = addressBook.getAllTagging(); | ||
for ( Tagging tagging : allTagging) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pay attention to the whitespace |
||
System.out.println(tagging.toString()); | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good job for writing this method. |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
package seedu.addressbook.data; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.HashSet; | ||
import java.util.Map; | ||
|
@@ -11,6 +12,7 @@ | |
import seedu.addressbook.data.person.UniquePersonList.DuplicatePersonException; | ||
import seedu.addressbook.data.person.UniquePersonList.PersonNotFoundException; | ||
import seedu.addressbook.data.tag.Tag; | ||
import seedu.addressbook.data.tag.Tagging; | ||
import seedu.addressbook.data.tag.UniqueTagList; | ||
|
||
/** | ||
|
@@ -24,13 +26,15 @@ public class AddressBook { | |
|
||
private final UniquePersonList allPersons; | ||
private final UniqueTagList allTags; // can contain tags not attached to any person | ||
private ArrayList<Tagging> allTagging; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good job for creating the Tagging list here. |
||
|
||
/** | ||
* Creates an empty address book. | ||
*/ | ||
public AddressBook() { | ||
allPersons = new UniquePersonList(); | ||
allTags = new UniqueTagList(); | ||
allTagging = new ArrayList<Tagging>(); | ||
} | ||
|
||
/** | ||
|
@@ -70,6 +74,23 @@ private void syncTagsWithMasterList(Person person) { | |
} | ||
person.setTags(new UniqueTagList(commonTagReferences)); | ||
} | ||
/** | ||
* Update Tags added for each person | ||
* @param tag | ||
* @param person | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better write a short description for each |
||
*/ | ||
private void updateAddedTags (Tag tag, ReadOnlyPerson person) { | ||
allTagging.add(new Tagging(tag, "+", person)); | ||
} | ||
/** | ||
* Update Tags deleted for each person | ||
* @param tag | ||
* @param person | ||
*/ | ||
private void updateDeletedTags (Tag tag, ReadOnlyPerson person) { | ||
allTagging.add(new Tagging(tag, "-", person)); | ||
} | ||
|
||
|
||
/** | ||
* Adds a person to the address book. | ||
|
@@ -120,6 +141,12 @@ public UniquePersonList getAllPersons() { | |
public UniqueTagList getAllTags() { | ||
return new UniqueTagList(allTags); | ||
} | ||
/** | ||
* Returns a new ArrayList of all Tagging in the address book at the time if the call | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
*/ | ||
public ArrayList<Tagging> getAllTagging() { | ||
return new ArrayList<Tagging>(allTagging); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object other) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package seedu.addressbook.data.tag; | ||
|
||
import seedu.addressbook.data.person.Person; | ||
import seedu.addressbook.data.person.ReadOnlyPerson; | ||
|
||
/** | ||
* Association class representing an addition/deletion of Tags for the person | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A more precise description is |
||
* @author shuqi | ||
* | ||
*/ | ||
public class Tagging { | ||
private Tag tag; | ||
private String action; | ||
private ReadOnlyPerson person; | ||
private String personName; | ||
|
||
public Tagging(Tag tag, String action, ReadOnlyPerson person2) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what is |
||
this.tag = tag; | ||
this.action = action; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better create different method for adding/removing a tag. |
||
this.person = person2; | ||
this.personName = this.person.getName().fullName; | ||
} | ||
|
||
public ReadOnlyPerson getPerson() { | ||
return this.person; | ||
} | ||
|
||
// get Name of person that Tags was added/deleted | ||
public String getPersonName() { | ||
return personName; | ||
} | ||
|
||
public String toString() { | ||
return action +" "+personName+" "+tag.toString(); | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prints