public class Contact extends Object implements Comparable<Contact>
Constructor and Description |
---|
Contact(Contact other)
Initialize this contact to have the same name and telephone number as
another contact.
|
Contact(String name,
PhoneNumber number)
Initialize this contact to have the specified name and telephone number.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Contact other)
Compares this contact with another contact for order.
|
boolean |
equals(Object obj)
Compares two contacts for equality.
|
String |
getName()
Returns the name of this contact.
|
PhoneNumber |
getNumber()
Returns the telephone number of this contact.
|
int |
hashCode()
Returns a hash code for this contact.
|
void |
setName(String name)
Sets the name of this contact.
|
void |
setNumber(PhoneNumber number)
Set the phone number for this contact.
|
String |
toString()
Returns a string representation of this contact.
|
public Contact(String name, PhoneNumber number)
name
- the name of this contactnumber
- the phone number of this contactpublic Contact(Contact other)
other
- the contact to copypublic String getName()
public final void setName(String name)
name
- the name to setpublic PhoneNumber getNumber()
public final void setNumber(PhoneNumber number)
number
- the phone number of this contactpublic int hashCode()
hashCode
in class Object
Object.hashCode()
public boolean equals(Object obj)
public int compareTo(Contact other)
compareTo
in interface Comparable<Contact>
other
- a contact to compare withpublic String toString()
toString
in class Object
Object.toString()