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.2i][F09-4] Rachel Lee #138

Open
wants to merge 5 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
3 changes: 2 additions & 1 deletion docs/DeveloperGuide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ Priorities: High (must have) - `* * \*`, Medium (nice to have) - `* \*`, Low (un
|===========================================================================================================================================
|Priority |As a ... |I want to ... |So that I can...
|`* * *` |new user |see usage instructions |refer to instructions when I forget how to use the App
|`* * *` |user |add a new person |
|`* * *` |user |add a new person | add details of people
|`* * *` |user |delete a person |remove entries that I no longer need
|`* * *` |user |find a person by name |locate details of persons without having to go through the entire list
|`* * *` |user |edit details of a person |update details or make small changes without having to remove and re-add the person
|`* *` |user |hide <<private-contact-detail, private contact details>> by default |minimize chance of someone else seeing them by accident
|`*` |user with many persons in the address book |sort persons by name |locate a person easily
|===========================================================================================================================================
Expand Down
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 @@ -55,4 +55,9 @@ public int hashCode() {
public boolean isPrivate() {
return isPrivate;
}

@Override
public String getPrintableString() {
return "Address: " + value;
}
}
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 @@ -58,4 +58,9 @@ public int hashCode() {
public boolean isPrivate() {
return isPrivate;
}

@Override
public String getPrintableString() {
return "Email: " + value;
}
}
6 changes: 5 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 alphanumeric characters";
Expand Down Expand Up @@ -61,4 +61,8 @@ public int hashCode() {
return fullName.hashCode();
}

@Override
public String getPrintableString() {
return "Name: " + fullName;
}
}
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: " + value;
}
}
9 changes: 9 additions & 0 deletions src/seedu/addressbook/data/person/Printable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package seedu.addressbook.data.person;

/**
* A printable interface for a Person in the addressbook.
* Implementations should guarantee: details are present and not null, field values are validated.
*/
public interface Printable {
String getPrintableString();
}
8 changes: 5 additions & 3 deletions src/seedu/addressbook/data/person/ReadOnlyPerson.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* A read-only immutable interface for a Person in the addressbook.
* Implementations should guarantee: details are present and not null, field values are validated.
*/
public interface ReadOnlyPerson {
public interface ReadOnlyPerson extends Printable{
Copy link

Choose a reason for hiding this comment

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

since this interface is implemented by the Person class, the new methods also need to be implemented in that class. Alternative is to have the Person class implementing Printable instead.


Name getName();
Phone getPhone();
Expand All @@ -33,14 +33,16 @@ default boolean isSameStateAs(ReadOnlyPerson other) {
&& other.getAddress().equals(this.getAddress()));
}

String getPrintableString();

/**
* Formats the person as text, showing all contact details.
*/
default String getAsTextShowAll() {
final StringBuilder builder = new StringBuilder();
final String detailIsPrivate = "(private) ";
builder.append(getName())
.append(" Phone: ");
builder.append(getPrintableString());
//.append(" Phone: ");
if (getPhone().isPrivate()) {
builder.append(detailIsPrivate);
}
Expand Down