|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectedu.colorado.simulations.SocialSecurityNumber
public class SocialSecurityNumber
A SocialSecurityNumber object holds the value of a single social security number. The methods of this class could be expanded to make the class more useful, but I have kept things basic to focus on how to implement the Comparable interface.
Note: A social security number is a nine-digit number broken into three groups in the form XXX-XX-XXXX. The first three digits (the "area") are between 001 and 799 (inclusive). The next two digits (the "group") are between 01 and 99 (inclusive). The last four digits (the "serial") are between 0001 and 9999 (inclusive).
| Constructor Summary | |
|---|---|
SocialSecurityNumber(int n)
Construct a SocialSecurityNumber from a specified number. |
|
| Method Summary | |
|---|---|
int |
compareTo(java.lang.Object o)
Compare this SocialSecurityNumber to another. |
void |
set(int n)
Set the value of this SocialSecurityNumber. |
java.lang.String |
toString()
Return the value of this Social Security Number as a String. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public SocialSecurityNumber(int n)
n - the social security number as an integer| Method Detail |
|---|
public int compareTo(java.lang.Object o)
compareTo in interface java.lang.Comparableo - the other SocialSecurityNumber to compare to.
java.lang.ClassCastException - Indicates that o is not a SocialSecurityNumber.public void set(int n)
public java.lang.String toString()
toString in class java.lang.Object
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||