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

[W5][W13-1]Yong Xin Shen #141

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
10 changes: 10 additions & 0 deletions src/seedu/addressbook/data/person/Person.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package seedu.addressbook.data.person;

import java.time.Instant;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
Expand All @@ -17,6 +18,8 @@ public class Person implements ReadOnlyPerson {
private Email email;
private Address address;

private Instant timeAdded;

private final Set<Tag> tags = new HashSet<>();

/**
Expand All @@ -28,6 +31,8 @@ public Person(Name name, Phone phone, Email email, Address address, Set<Tag> tag
this.email = email;
this.address = address;
this.tags.addAll(tags);

this.timeAdded = Instant.now();
}

/**
Expand Down Expand Up @@ -57,6 +62,11 @@ public Address getAddress() {
return address;
}

@Override
public Instant getTimeAdded() {
return timeAdded;
}

@Override
public Set<Tag> getTags() {
return new HashSet<>(tags);
Expand Down
5 changes: 5 additions & 0 deletions src/seedu/addressbook/data/person/ReadOnlyPerson.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package seedu.addressbook.data.person;

import java.time.Instant;
import java.util.Set;

import seedu.addressbook.data.tag.Tag;
Expand All @@ -14,6 +15,7 @@ public interface ReadOnlyPerson {
Phone getPhone();
Email getEmail();
Address getAddress();
Instant getTimeAdded();

/**
* Returns a new TagSet that is a deep copy of the internal TagSet,
Expand Down Expand Up @@ -89,6 +91,9 @@ default String getAsTextHidePrivate() {
if (!getAddress().isPrivate()) {
builder.append(" Address: ").append(getAddress());
}

builder.append(" DateTime added: ").append(getTimeAdded());

builder.append(" Tags: ");
for (Tag tag : getTags()) {
builder.append(tag);
Expand Down
1 change: 1 addition & 0 deletions test/java/seedu/addressbook/commands/AddCommandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public void addCommand_validData_correctlyConstructed() throws Exception {
assertTrue(p.getAddress().isPrivate());
boolean isTagListEmpty = !p.getTags().iterator().hasNext();
assertTrue(isTagListEmpty);
assertFalse(p.getTimeAdded().toString().isEmpty());
}

@Test
Expand Down