diff options
| author | mokha <mokha@cisco.com> | 2019-05-06 20:41:58 -0600 |
|---|---|---|
| committer | mokha <mokha@cisco.com> | 2019-05-06 20:41:58 -0600 |
| commit | 60b69a3d01db893ac1415678574d0fa4ce11cfa4 (patch) | |
| tree | d32c812ee607f75e5f789aa798f0e261e2d337db | |
| parent | 3f56b920e5d25beb49bb9d6e8bc2927b42caf51a (diff) | |
complete documentation for AddressBook.
| -rw-r--r-- | src/Q1/AddressBook.java | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/src/Q1/AddressBook.java b/src/Q1/AddressBook.java index 4b69d18..fa84c26 100644 --- a/src/Q1/AddressBook.java +++ b/src/Q1/AddressBook.java @@ -184,52 +184,123 @@ public class AddressBook implements Comparable<AddressBook> { this.businessPhone = value; } + /** + * Sets the cell phone number. + * + * @param value The new cell phone number. + */ public void setCellPhone(String value) { this.cellPhone = value; } + /** + * Sets the Facebook Id. + * + * @param value The new Facebook id. + */ public void setFacebookId(String value) { this.facebookId = value; } + /** + * Sets the first name. + * + * @param name the new first name. + */ public void setFirstName(String name) { this.firstName = name; } + /** + * Sets the home address. + * + * @param address new home address. + */ public void setHomeAddress(String address) { this.homeAddress = address; } + /** + * Sets the home phone number. + * + * @param value the new home phone number. + */ public void setHomePhone(String value) { this.homePhone = value; } + /** + * Sets the last name. + * + * @param name the last name. + */ public void setLastName(String name) { this.lastName = name; } + /** + * Sets the middle name. + * + * @param name the middle name. + */ public void setMiddleName(String name) { this.middleName = name; } + /** + * Sets the personal website. + * + * @param value the personal website + */ public void setPersonalWebSite(String value) { this.personalWebSite = value; } + /** + * Sets the Skype Id. + * + * @param value the Skype Id. + */ public void setSkypeId(String value) { this.skypeId = value; } + /** + * Compares name1 with name2 and returns a string representation. + * Returns a negative value if name1 is less than name2. + * Returns a positive value if name1 is greater than name2. + * Returns a zero if name1 is equal to name2. + * + * @param name1 first name + * @param name2 second name + * @return string version of -1, 0, 1 + */ public static String compareNames(String name1, String name2) { return Integer.toString(name1.compareTo(name2)); } + /** + * Compares one address book with another. + * Returns a negative value if this is less than other. + * Returns a positive value if this is greater than other. + * Returns a zero if this is equal to other. + * + * @param other The other address book to compare to. + */ public int compareTo(AddressBook other) { return this.firstName.compareTo(other.firstName) + this.middleName.compareTo(other.middleName) + this.lastName.compareTo(other.lastName); } + /** + * Overrides equals to check for value equality instead of + * reference equality. + * + * @param o The other item to check against. + * + * @return true if values match, otherwise false. + */ @Override public boolean equals(Object o) { if (this == o) return true; @@ -247,6 +318,13 @@ public class AddressBook implements Comparable<AddressBook> { && Objects.equals(skypeId, that.skypeId); } + /** + * Overrides hashCode to ensure instances that are + * equal by value equate to the same hash code for + * hash key computations. + * + * @return The hash code + */ @Override public int hashCode() { return Objects.hash( @@ -262,6 +340,11 @@ public class AddressBook implements Comparable<AddressBook> { skypeId); } + /** + * Overrides toString to return the first name of the contact. + * + * @return the first name of the contact. + */ @Override public String toString() { return this.firstName; |
