Class Name

java.lang.Object
  |
  +--Name

public class Name
extends java.lang.Object

The Name class is used to store a person's name. Currently it only supports first and last names.

This is proably overkill for such a simple object but its purpose is to demonstrate a functional object.


Constructor Summary
Name()
          Constructor
Name(Name obj)
          Clone Constructor
Name(java.lang.String first, java.lang.String last)
          Full Constructor
 
Method Summary
 boolean equals(java.lang.Object obj)
          Determine if an object is equal to this object.
 java.lang.String getFirst()
          Get the value of first.
 java.lang.String getLast()
          Get the value of last.
 int hashCode()
          Override the default hashCode() method.
 void setFirst(java.lang.String first)
          Set the value of first
 void setLast(java.lang.String last)
          Set the value of last
 java.lang.String toString()
          Convert object to String
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Name

public Name()
Constructor

Name

public Name(Name obj)
Clone Constructor
Parameters:
obj - clone this object.

Name

public Name(java.lang.String first,
            java.lang.String last)
Full Constructor
Parameters:
first - - First name
last - - Last name
Method Detail

setFirst

public void setFirst(java.lang.String first)
Set the value of first
Parameters:
first - First name

getFirst

public java.lang.String getFirst()
Get the value of first.
Returns:
First name

setLast

public void setLast(java.lang.String last)
Set the value of last
Parameters:
last - Last name

getLast

public java.lang.String getLast()
Get the value of last.
Returns:
Last name

toString

public java.lang.String toString()
Convert object to String
Overrides:
toString in class java.lang.Object
Returns:
Name as "First Last".

equals

public boolean equals(java.lang.Object obj)
Determine if an object is equal to this object.
Overrides:
equals in class java.lang.Object
Parameters:
obj - the object to test.
Returns:
true if obj is equal to this object.

hashCode

public int hashCode()
Override the default hashCode() method. This allows classes like Vector and Hashtable to quickly identify an object.
Overrides:
hashCode in class java.lang.Object
Returns:
a "unique" hashCode for this object.