-
Notifications
You must be signed in to change notification settings - Fork 141
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][F09-B4]Zhong ZhengXin #734
base: master
Are you sure you want to change the base?
Changes from all commits
323c944
f0bec46
c95c9b8
dbbbd36
cbf7905
dda9e7b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 = "[email protected]"; | ||
public static final String MESSAGE_EMAIL_CONSTRAINTS = | ||
|
@@ -58,4 +58,14 @@ public int hashCode() { | |
public boolean isPrivate() { | ||
return isPrivate; | ||
} | ||
|
||
@Override | ||
public String getPrintableString() { | ||
if(isPrivate) { | ||
return "Email: " + " (private)" + value ; | ||
} | ||
else{ | ||
return "Email: " + value ; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,20 @@ public Person(ReadOnlyPerson source) { | |
this(source.getName(), source.getPhone(), source.getEmail(), source.getAddress(), source.getTags()); | ||
} | ||
|
||
/** | ||
* Returns a concatenated version of the printable strings of each object. | ||
*/ | ||
String getPrintableString(Printable... printables){ | ||
String concatenatedStringResult = ""; | ||
|
||
for(Printable p: printables) { | ||
|
||
concatenatedStringResult.concat(p.getPrintableString() + " "); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another way you can do this is using the |
||
} | ||
|
||
return concatenatedStringResult.toString(); | ||
} | ||
|
||
@Override | ||
public Name getName() { | ||
return name; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package seedu.addressbook.data.person; | ||
|
||
public interface Printable { | ||
/** | ||
*Produces a printable string representation of the object | ||
*/ | ||
String getPrintableString(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good job having a header comment for this method. You may want to have a header comment for the interface, as well. |
||
} |
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.
Ideally, this method should be used somewhere.