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][T09-B3] Kang Anmin #966

Open
wants to merge 5 commits 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
13 changes: 12 additions & 1 deletion src/seedu/addressbook/commands/ExitCommand.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package seedu.addressbook.commands;

import java.util.Arrays;
import seedu.addressbook.data.AddressBook;
import seedu.addressbook.data.tag.Tagging;

/**
* Terminates the program.
*/
Expand All @@ -13,7 +17,14 @@ public class ExitCommand extends Command {

@Override
public CommandResult execute() {
return new CommandResult(MESSAGE_EXIT_ACKNOWEDGEMENT);

StringBuffer tagLog = new StringBuffer();

for(Tagging tagging: addressBook.tagLog) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coding standard violation. Missing an empty space.

tagLog.append(tagging.toString() + "\n");
}

return new CommandResult(tagLog + MESSAGE_EXIT_ACKNOWEDGEMENT);
}

public static boolean isExit(Command command) {
Expand Down
5 changes: 5 additions & 0 deletions src/seedu/addressbook/data/AddressBook.java
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;
Expand All @@ -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;

/**
Expand All @@ -24,13 +26,15 @@ public class AddressBook {

private final UniquePersonList allPersons;
private final UniqueTagList allTags; // can contain tags not attached to any person
public ArrayList<Tagging> tagLog;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good, this is a correct place to put the list based on the UML.. May be tagList is a better name.


/**
* Creates an empty address book.
*/
public AddressBook() {
allPersons = new UniquePersonList();
allTags = new UniqueTagList();
tagLog = new ArrayList<Tagging>();
}

/**
Expand All @@ -46,6 +50,7 @@ public AddressBook(UniquePersonList persons, UniqueTagList tags) {
for (Person p : allPersons) {
syncTagsWithMasterList(p);
}
tagLog = new ArrayList<Tagging>();
}

/**
Expand Down
28 changes: 28 additions & 0 deletions src/seedu/addressbook/data/tag/Tagging.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package seedu.addressbook.data.tag;

import seedu.addressbook.data.person.Person;

/**
* It records a transaction of a tag addition/deletion

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can start with Records ....

*/
public class Tagging {
private Person person;
private Tag tag;
private boolean addition; // true means it is an addition, false means deletion

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coding standard violation for boolean.
Using boolean is fine now since this LO requires only two states. What if later you need to capture more than two states?


/**
* Constructs a tagging with the given data.
*
* @param person the person whose tag was added/deleted in the last transaction
* @param tag the tag added/deleted in the last transaction
*/
public Tagging(Person person, Tag tag, boolean addition) {
this.person = person;
this.tag = tag;
this.addition = addition;
}

public String toString() {
return (addition?"+ ":"- ") + person.getName() + " " + tag.toString();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this ternary operator violates our coding standard. Missing empty spaces?

}
}