public class PhoneGenerator
extends java.lang.Object
While numbers could be totally randomly picked, generally you have a set of similar area code and prefixes for the same person.
To use, create an instance of PhoneGenerator then invoke nextNewNumber
, nextNumber
, or to
get a sequence of random phone numbers.
Example:
// Generate groups of 4 numbers having the name area code and prefix. PhoneGenerator gen = new PhoneGenerator (); for (int i = 0; i < count; i++) { System.out.println (gen.nextNumber ()); if (i % 4 == 0) { System.out.println (); gen.reset (); } }
Sample output:
(358) 194-4549 (358) 917-5857 (358) 917-8755 (358) 917-1203 (358) 917-9490 (358) 572-2284 (358) 572-9957 (358) 572-4731 (358) 572-8766 (358) 618-3093
Modifier and Type | Class and Description |
---|---|
static class |
PhoneGenerator.PhoneNumber
Represents a randomly generated phone number and its parts.
|
static class |
PhoneGenerator.Test
Inner test class.
|
Constructor and Description |
---|
PhoneGenerator() |
Modifier and Type | Method and Description |
---|---|
PhoneGenerator.PhoneNumber |
nextNewNumber()
Return the next number with a new area code and prefix.
|
PhoneGenerator.PhoneNumber |
nextNumber()
Fetch the next number with the same area code and prefix.
|
void |
reset()
Reset the area code and prefix so that the next call to nextNumber
or nextNumberWithExtension will generate a new one.
|
public PhoneGenerator.PhoneNumber nextNumber()
public PhoneGenerator.PhoneNumber nextNewNumber()
public void reset()
Copyright ? 2002 Clarity Systems Group, LLC. All Rights Reserved.