diff options
| author | mokha <mokha@cisco.com> | 2019-05-05 19:57:14 -0600 |
|---|---|---|
| committer | mokha <mokha@cisco.com> | 2019-05-05 19:57:14 -0600 |
| commit | 7b4cb6a2eef3a0fcde7e998832427c73599e4a0a (patch) | |
| tree | 75acc7cd8f3bd8a087e909db182c9e18a66879a1 /src/Q1/AddressBook.java | |
| parent | 99a28d2dba93642e89a62ecf905a3bd4f138318d (diff) | |
use the exact naming convention for directories described by instructor
Diffstat (limited to 'src/Q1/AddressBook.java')
| -rw-r--r-- | src/Q1/AddressBook.java | 178 |
1 files changed, 178 insertions, 0 deletions
diff --git a/src/Q1/AddressBook.java b/src/Q1/AddressBook.java new file mode 100644 index 0000000..9fcfa82 --- /dev/null +++ b/src/Q1/AddressBook.java @@ -0,0 +1,178 @@ +package ca.mokhan.assignment1; + +import java.util.Objects; + +public class AddressBook implements Comparable<AddressBook> { + private String businessPhone; + private String cellPhone; + private String facebookId; + private String firstName = ""; + private String homeAddress; + private String homePhone; + private String lastName = ""; + private String middleName = ""; + private String personalWebSite; + private String skypeId; + + public AddressBook() { + this(""); + } + + public AddressBook(String firstName) { + this(firstName, "", ""); + } + + public AddressBook(String firstName, String middleName, String lastName) { + this(firstName, middleName, lastName, "", "", "", "", "", "", ""); + } + + public AddressBook( + String firstName, + String middleName, + String lastName, + String businessPhone, + String cellPhone, + String facebookId, + String homeAddress, + String homePhone, + String personalWebSite, + String skypeId) { + this.businessPhone = businessPhone; + this.cellPhone = cellPhone; + this.facebookId = facebookId; + this.firstName = firstName; + this.homeAddress = homeAddress; + this.homePhone = homePhone; + this.lastName = lastName; + this.middleName = middleName; + this.personalWebSite = personalWebSite; + this.skypeId = skypeId; + } + + public String getBusinessPhone() { + return this.businessPhone; + } + + public String getCellPhone() { + return this.cellPhone; + } + + public String getFacebookId() { + return this.facebookId; + } + + public String getFirstName() { + return this.firstName; + } + + public String getHomeAddress() { + return this.homeAddress; + } + + public String getHomePhone() { + return this.homePhone; + } + + public String getLastName() { + return this.lastName; + } + + public String getMiddleName() { + return this.middleName; + } + + public String getPersonalWebSite() { + return this.personalWebSite; + } + + public String getSkypeId() { + return this.skypeId; + } + + public void setBusinessPhone(String value) { + this.businessPhone = value; + } + + public void setCellPhone(String value) { + this.cellPhone = value; + } + + public void setFacebookId(String value) { + this.facebookId = value; + } + + public void setFirstName(String name) { + this.firstName = name; + } + + public void setHomeAddress(String address) { + this.homeAddress = address; + } + + public void setHomePhone(String value) { + this.homePhone = value; + } + + public void setLastName(String name) { + this.lastName = name; + } + + public void setMiddleName(String name) { + this.middleName = name; + } + + public void setPersonalWebSite(String value) { + this.personalWebSite = value; + } + + public void setSkypeId(String value) { + this.skypeId = value; + } + + public static String compareNames(String name1, String name2) { + return Integer.toString(name1.compareTo(name2)); + } + + public int compareTo(AddressBook other) { + return this.firstName.compareTo(other.firstName) + + this.middleName.compareTo(other.middleName) + + this.lastName.compareTo(other.lastName); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof AddressBook)) return false; + AddressBook that = (AddressBook) o; + return Objects.equals(businessPhone, that.businessPhone) + && Objects.equals(cellPhone, that.cellPhone) + && Objects.equals(facebookId, that.facebookId) + && Objects.equals(firstName, that.firstName) + && Objects.equals(homeAddress, that.homeAddress) + && Objects.equals(homePhone, that.homePhone) + && Objects.equals(lastName, that.lastName) + && Objects.equals(middleName, that.middleName) + && Objects.equals(personalWebSite, that.personalWebSite) + && Objects.equals(skypeId, that.skypeId); + } + + @Override + public int hashCode() { + return Objects.hash( + businessPhone, + cellPhone, + facebookId, + firstName, + homeAddress, + homePhone, + lastName, + middleName, + personalWebSite, + skypeId); + } + + @Override + public String toString() { + return this.firstName; + } +} |
