Class Person

java.lang.Object
  |
  +--Person
All Implemented Interfaces:
java.lang.Comparable

public class Person
extends java.lang.Object
implements java.lang.Comparable

Class Person is a class to represent people


Constructor Summary
Person(java.lang.String idNumber, java.lang.String first, java.lang.String last)
          A constructor from two Strings
 
Method Summary
 int compareTo(java.lang.Object rhs)
          Compares this Person to another Person using String compareTo on lastName and then firstName and then the idNumber.
 boolean equals(java.lang.Object aPerson)
          Person objects are equal if the idNumbers are equal
 java.lang.String getFirstName()
          Retrieve the first name
 java.lang.String getIdNumber()
          Retrieve the idNumber
 java.lang.String getLastName()
          Retrieve the last name
 int hashCode()
          Returns an int value asociated with this object
 void setFirstName(java.lang.String newName)
          Change the first name
 void setLastName(java.lang.String newName)
          Change the last name
 java.lang.String toString()
          Returns a String representation of the data in class Person
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Person

public Person(java.lang.String idNumber,
              java.lang.String first,
              java.lang.String last)
A constructor from two Strings

Parameters:
first - is the person first name
last - is the person's last name
Method Detail

getIdNumber

public java.lang.String getIdNumber()
Retrieve the idNumber

Returns:
the idNumber as a String

getFirstName

public java.lang.String getFirstName()
Retrieve the first name

Returns:
the first name as a String

getLastName

public java.lang.String getLastName()
Retrieve the last name

Returns:
the last name as a String

setLastName

public void setLastName(java.lang.String newName)
Change the last name

Parameters:
newName - is the new last name

setFirstName

public void setFirstName(java.lang.String newName)
Change the first name

Parameters:
newName - is the new first name

equals

public boolean equals(java.lang.Object aPerson)
Person objects are equal if the idNumbers are equal

Overrides:
equals in class java.lang.Object
Returns:
true if the idNumbers match; false otherwise

hashCode

public int hashCode()
Returns an int value asociated with this object

Overrides:
hashCode in class java.lang.Object
Returns:
a hash code value for the object.

compareTo

public int compareTo(java.lang.Object rhs)
Compares this Person to another Person using String compareTo on lastName and then firstName and then the idNumber. If the lastName is empty then the first name is used

Specified by:
compareTo in interface java.lang.Comparable
Returns:
an int < 0 if less; an int == 0 if equal; an int >0 if greater

toString

public java.lang.String toString()
Returns a String representation of the data in class Person

Overrides:
toString in class java.lang.Object
Returns:
a string of the objects in Person