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

[T4A1][T1-04] Aung Swumm #112

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
7 changes: 6 additions & 1 deletion src/seedu/addressbook/data/person/Address.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -41,6 +41,11 @@ public String toString() {
return value;
}

@Override
public String getPrintableString() {
return "Address: " + this.toString();
}
Copy link

@jeffryhartanto jeffryhartanto Jul 8, 2017

Choose a reason for hiding this comment

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

Shouldn't you check whether it's private or not? When do you combine all the printables?


@Override
public boolean equals(Object other) {
return other == this // short circuit if same object
Expand Down
7 changes: 6 additions & 1 deletion src/seedu/addressbook/data/person/Email.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -42,6 +42,11 @@ public String toString() {
return value;
}

@Override
public String getPrintableString() {
return "Email: " + this.toString();
}

@Override
public boolean equals(Object other) {
return other == this // short circuit if same object
Expand Down
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,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 alphabetic characters";
Expand Down Expand Up @@ -43,6 +43,11 @@ public List<String> getWordsInName() {
return Arrays.asList(fullName.split("\\s+"));
}

@Override
public String getPrintableString() {
return "Name: " + this.toString();
}

@Override
public String toString() {
return fullName;
Expand Down
7 changes: 6 additions & 1 deletion src/seedu/addressbook/data/person/Phone.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -56,4 +56,9 @@ public int hashCode() {
public boolean isPrivate() {
return isPrivate;
}

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

//an interface that allows user to access data on a read-only, immutable basis

Choose a reason for hiding this comment

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

Good that you write the header comment, but try to follow the coding standard for this. Check out ReadOnlyPerson interface for reference.

public interface Printable {
public abstract String getPrintableString();

public default String getPrintableString(Printable...printables) {
StringBuilder printableString = new StringBuilder();
for (Printable _printable : printables) {
printableString.append(_printable.getPrintableString());
}
return printableString.toString();

Choose a reason for hiding this comment

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

This code shouldn't be here and also this method is never called. Discuss with your teammates.

}
}