| Constructor and Description |
|---|
Person(java.lang.String name,
int age,
java.lang.String contactInfo)
Initializes this Person object with the passed name, age, and contact.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(Person other)
Compares this object with the passed one.
|
boolean |
equals(java.lang.Object obj)
Tests equality between this object and the passed one.
|
int |
getAge()
Returns this person's age.
|
java.lang.String |
getContactInfo()
Returns this person's contact information.
|
java.lang.String |
getName()
Returns this person's name.
|
void |
setAge(int age)
Sets this person's age.
|
void |
setContactInfo(java.lang.String contactInfo)
Sets the person's contact info.
|
void |
setName(java.lang.String name)
Sets this person's name.
|
java.lang.String |
toString()
Returns a String representation of this object, comprised of the
name, age, and contact information, as in the following example:
Jane Doe, age: 32, contact: 321-555-1234
|
public Person(java.lang.String name,
int age,
java.lang.String contactInfo)
throws java.lang.IllegalArgumentException
name - the name for this Personage - the age for this PersoncontactInfo - the contact information for this personjava.lang.IllegalArgumentException - if age < 0public java.lang.String getName()
public void setName(java.lang.String name)
name - the name to setpublic int getAge()
public void setAge(int age)
throws java.lang.IllegalArgumentException
age - the age to setjava.lang.IllegalArgumentException - if age < 0public java.lang.String getContactInfo()
public void setContactInfo(java.lang.String contactInfo)
contactInfo - the contactInfo to setpublic java.lang.String toString()
toString in class java.lang.ObjectObject.toString()public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - the object to test for equalityObject.equals(java.lang.Object)public int compareTo(Person other)
compareTo in interface java.lang.Comparable<Person>other - the other Person object to compareComparable.compareTo(java.lang.Object)