Source of ImmutableName.java


  1: /**
  2:    An immutable class that represents a person's name.
  3:    
  4:    @author Frank M. Carrano
  5:    @author Timothy M. Henry
  6:    @version 5.0
  7: */
  8:  public final class ImmutableName
  9: {
 10:    private String first; // First name
 11:    private String last;  // Last name

 13:    public ImmutableName(String firstName, String lastName)
 14:    {
 15:       first = firstName;
 16:       last = lastName;
 17:    } // end constructor

 19:    public String getFirst()
 20:    {
 21:       return first;
 22:    } // end getFirst

 24:    public String getLast()
 25:    {
 26:       return last;
 27:    } // end getLast

 29:    public String getName()
 30:    {
 31:       return toString();
 32:    } // end getName

 34:    public String toString()
 35:    {
 36:       return first + " " + last;
 37:    } // end toString
 38: } // end ImmutableName