Class FamousName

java.lang.Object
  extended by FamousName

public class FamousName
extends java.lang.Object

FamousName is the first name of a famous person. It is a special kind of string of length > 1 that contains only uppercase alphabetic characters.

Version:
2008.09.28
Author:
J. Dalbey

Constructor Summary
FamousName()
          Construct an empty name.
FamousName(java.lang.String rawname)
          Construct a FamousName from a string.
 
Method Summary
 int compareTo(FamousName val)
          Compares this FamousName with the provided FamousName.
 boolean equals(java.lang.Object other)
          Compare two FamousNames for equality.
static boolean isLegalName(java.lang.String rawname)
          Determine if a string is a legal name.
 java.lang.String toString()
          Return a string representation of this FamousName
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FamousName

public FamousName()
Construct an empty name.


FamousName

public FamousName(java.lang.String rawname)
Construct a FamousName from a string.

Parameters:
rawname - a String to be assigned to this FamousName
Postcondition:
if isLegalName(rawname) then a FamousName is created from rawname otherwise an empty FamousName is created.
Method Detail

isLegalName

public static boolean isLegalName(java.lang.String rawname)
Determine if a string is a legal name.

Parameters:
rawname - a string to be evaluated for validity
Returns:
true if all characters in rawname are alphabetic and the length > 1.

compareTo

public int compareTo(FamousName val)
Compares this FamousName with the provided FamousName.

Parameters:
val - FamousName to which this FamousName is to be compared.
Returns:
-1, 0 or 1 as this FamousName is alphabetically less than, equal to, or greater than val.

equals

public boolean equals(java.lang.Object other)
Compare two FamousNames for equality. This method is provided to facilitate JUnit testing.

Overrides:
equals in class java.lang.Object
Parameters:
other - the other name to be compared
Returns:
true if other is equal to this FamousName.

toString

public java.lang.String toString()
Return a string representation of this FamousName

Overrides:
toString in class java.lang.Object
Returns:
the formatted name