diff --git a/src/seedu/addressbook/data/person/Address.java b/src/seedu/addressbook/data/person/Address.java index 8ac726444..21174d779 100644 --- a/src/seedu/addressbook/data/person/Address.java +++ b/src/seedu/addressbook/data/person/Address.java @@ -6,7 +6,7 @@ * Represents a Person's address in the address book. * Guarantees: immutable; is valid as declared in {@link #isValidAddress(String)} */ -public class Address { +public class Address implements Printable { public static final String EXAMPLE = "123, some street"; public static final String MESSAGE_ADDRESS_CONSTRAINTS = "Person addresses can be in any format"; @@ -55,4 +55,8 @@ public int hashCode() { public boolean isPrivate() { return isPrivate; } + + public String getPrintableString() { + return value; + } } \ No newline at end of file diff --git a/src/seedu/addressbook/data/person/Email.java b/src/seedu/addressbook/data/person/Email.java index c946f1eb3..eb04809df 100644 --- a/src/seedu/addressbook/data/person/Email.java +++ b/src/seedu/addressbook/data/person/Email.java @@ -6,7 +6,7 @@ * Represents a Person's email in the address book. * Guarantees: immutable; is valid as declared in {@link #isValidEmail(String)} */ -public class Email { +public class Email implements Printable{ public static final String EXAMPLE = "valid@e.mail"; public static final String MESSAGE_EMAIL_CONSTRAINTS = @@ -58,4 +58,8 @@ public int hashCode() { public boolean isPrivate() { return isPrivate; } + + public String getPrintableString() { + return value; + } } \ No newline at end of file diff --git a/src/seedu/addressbook/data/person/Name.java b/src/seedu/addressbook/data/person/Name.java index 487b7ad9c..9fb6f3bca 100644 --- a/src/seedu/addressbook/data/person/Name.java +++ b/src/seedu/addressbook/data/person/Name.java @@ -9,7 +9,7 @@ * Represents a Person's name in the address book. * Guarantees: immutable; is valid as declared in {@link #isValidName(String)} */ -public class Name { +public class Name implements Printable{ public static final String EXAMPLE = "John Doe"; public static final String MESSAGE_NAME_CONSTRAINTS = "Person names should be spaces or alphanumeric characters"; @@ -61,4 +61,7 @@ public int hashCode() { return fullName.hashCode(); } + public String getPrintableString() { + return fullName; + } } diff --git a/src/seedu/addressbook/data/person/Person.java b/src/seedu/addressbook/data/person/Person.java index cf6211841..aed452379 100644 --- a/src/seedu/addressbook/data/person/Person.java +++ b/src/seedu/addressbook/data/person/Person.java @@ -34,6 +34,14 @@ public Person(ReadOnlyPerson source) { this(source.getName(), source.getPhone(), source.getEmail(), source.getAddress(), source.getTags()); } + public String getPrintableString(Printable... printables) { + String result = ""; + for (Printable i: printables) { + result = result + i.getPrintableString(); + } + return result; + } + @Override public Name getName() { return name; diff --git a/src/seedu/addressbook/data/person/Phone.java b/src/seedu/addressbook/data/person/Phone.java index b5a556de4..5b3001da0 100644 --- a/src/seedu/addressbook/data/person/Phone.java +++ b/src/seedu/addressbook/data/person/Phone.java @@ -6,7 +6,7 @@ * Represents a Person's phone number in the address book. * Guarantees: immutable; is valid as declared in {@link #isValidPhone(String)} */ -public class Phone { +public class Phone implements Printable{ public static final String EXAMPLE = "123456789"; public static final String MESSAGE_PHONE_CONSTRAINTS = "Person phone numbers should only contain numbers"; @@ -56,4 +56,8 @@ public int hashCode() { public boolean isPrivate() { return isPrivate; } + + public String getPrintableString() { + return value; + } } diff --git a/src/seedu/addressbook/data/person/Printable.java b/src/seedu/addressbook/data/person/Printable.java new file mode 100644 index 000000000..9c6639d89 --- /dev/null +++ b/src/seedu/addressbook/data/person/Printable.java @@ -0,0 +1,5 @@ +package seedu.addressbook.data.person; + +public interface Printable { + public String getPrintableString(); +} \ No newline at end of file