forked from se-edu/addressbook-level2
-
Notifications
You must be signed in to change notification settings - Fork 153
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-B4] Chua Li Qun Shawn #961
Open
shawnclq
wants to merge
9
commits into
nus-cs2103-AY1718S2:master
Choose a base branch
from
shawnclq:W8.6b
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d2ba0b7
Add Block.java, PostalCode.java, Street.java, Unit.java
dea1e13
Edit Address class to include Block, Street, Unit and PostalCode class.
5199faf
Edit AddCommand.java, expected.txt and input.txt to include new tests…
393028f
Edit expected.txt and input.txt to include new test cases
392973c
Update UserGuide.md and ValidData.xml to include new Block, Street, U…
23b71fb
Merge pull request #1 from shawnclq/W4.4b
shawnclq 1c1911b
Revert master to original addressbook2
9a57535
Revert master back to original addressbook2
425a37a
Add Tagging class
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Empty file.
Empty file.
Empty file.
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file modified
0
src/seedu/addressbook/data/exception/DuplicateDataException.java
100644 → 100755
Empty file.
Empty file modified
0
src/seedu/addressbook/data/exception/IllegalValueException.java
100644 → 100755
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package seedu.addressbook.data.tag; | ||
|
||
import seedu.addressbook.data.person.Person; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Objects; | ||
|
||
/** | ||
* Represents addition or deletion of tag for a person during a session | ||
* | ||
* Used for displaying tags changed at the end of a session | ||
*/ | ||
|
||
public class Tagging { | ||
private static ArrayList<Tagging> taggings; | ||
|
||
public enum Action { | ||
ADD, DELETE | ||
} | ||
|
||
private static final String ADD_TAG_SIGN = "+"; | ||
private static final String DELETE_TAG_SIGN = "-"; | ||
|
||
private final Person person; | ||
private final Tag tag; | ||
private final Action action; | ||
|
||
/** | ||
* @param person person whose tag was changed | ||
* @param tag tag that was changed | ||
* @param action type of action executed | ||
*/ | ||
public Tagging(Person person, Tag tag, Action action) { | ||
this.person = person; | ||
this.tag = tag; | ||
this.action = action; | ||
} | ||
|
||
/** | ||
* Adds tagging to class-level variable that stores all taggings | ||
*/ | ||
public static void addTagging(Tagging tagging) { | ||
taggings.add(tagging); | ||
} | ||
|
||
/** | ||
* Accessor method for obtaining taggings. | ||
* @return all Taggings, representing all changes made to tags since start of session | ||
*/ | ||
public static ArrayList<Tagging> getTaggings() { | ||
return taggings; | ||
} | ||
|
||
public Person getPerson() { | ||
return person; | ||
} | ||
|
||
public Tag getTag() { | ||
return tag; | ||
} | ||
|
||
public Action getAction() { | ||
return action; | ||
} | ||
|
||
@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).getAction().equals(this.getAction()); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(person, tag, action); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
StringBuilder builder = new StringBuilder(); | ||
|
||
if (this.action == Action.ADD) { | ||
builder.append(ADD_TAG_SIGN); | ||
} else { | ||
builder.append(DELETE_TAG_SIGN); | ||
} | ||
|
||
builder.append(" " + person.getName() + " " + tag); | ||
return builder.toString(); | ||
} | ||
} |
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This forces the caller to manually call
addTagging
after creating a newTagging
. If he doesn't, the doc comment forgetTaggings
will be incorrect. One way to solve this would be to move this method into the constructor. Alternatively, a new singletonTaggingList
class can be created.