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

[W6.4H][T16-B1] Qiu Haoze #764

Open
wants to merge 2 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
8 changes: 7 additions & 1 deletion src/seedu/addressbook/data/person/Address.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
* 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";
public static final String ADDRESS_VALIDATION_REGEX = ".+";
public static final String PRINTABLE_HEADER = "Address: ";

public final String value;
private boolean isPrivate;
Expand Down Expand Up @@ -55,4 +56,9 @@ public int hashCode() {
public boolean isPrivate() {
return isPrivate;
}

@Override
public String getPrintableString(){
return PRINTABLE_HEADER + toString();
}
}
8 changes: 7 additions & 1 deletion src/seedu/addressbook/data/person/Email.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
* 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 = "[email protected]";
public static final String MESSAGE_EMAIL_CONSTRAINTS =
"Person emails should be 2 alphanumeric/period strings separated by '@'";
public static final String EMAIL_VALIDATION_REGEX = "[\\w\\.]+@[\\w\\.]+";
public static final String PRINTABLE_HEADER = "Email: ";

public final String value;
private boolean isPrivate;
Expand Down Expand Up @@ -58,4 +59,9 @@ public int hashCode() {
public boolean isPrivate() {
return isPrivate;
}

@Override
public String getPrintableString(){
return PRINTABLE_HEADER + toString();
}
}
7 changes: 6 additions & 1 deletion src/seedu/addressbook/data/person/Name.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
* 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";
public static final String NAME_VALIDATION_REGEX = "[\\p{Alnum} ]+";
public static final String PRINTABLE_HEADER = "Name: ";

public final String fullName;

Expand Down Expand Up @@ -61,4 +62,8 @@ public int hashCode() {
return fullName.hashCode();
}

@Override
public String getPrintableString(){
return PRINTABLE_HEADER + toString();
}
}
8 changes: 7 additions & 1 deletion src/seedu/addressbook/data/person/Phone.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
* 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";
public static final String PHONE_VALIDATION_REGEX = "\\d+";
public static final String PRINTABLE_HEADER = "Phone: ";

public final String value;
private boolean isPrivate;
Expand Down Expand Up @@ -56,4 +57,9 @@ public int hashCode() {
public boolean isPrivate() {
return isPrivate;
}

@Override
public String getPrintableString(){
return PRINTABLE_HEADER + toString();
}
}
5 changes: 5 additions & 0 deletions src/seedu/addressbook/data/person/Printable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package seedu.addressbook.data.person;

public interface Printable {
String getPrintableString();
}
8 changes: 8 additions & 0 deletions src/seedu/addressbook/data/person/ReadOnlyPerson.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,12 @@ default String getAsTextHidePrivate() {
}
return builder.toString();
}

default String getPrintableString(Printable... printables){
String concatenated = "";
for (Printable p : printables){
concatenated += p.getPrintableString();

Choose a reason for hiding this comment

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

string builder would be more efficient

}
return concatenated;
}
}