goldman.collection
Class IndexedNumber

java.lang.Object
  extended by goldman.collection.IndexedNumber

public class IndexedNumber
extends Object

The IndexedNumber class illustrates a way to provide access to the digits of a number.


Nested Class Summary
static class IndexedNumber.NumberDigitizer
          This class provides a sample implementation for the Digitizer interface for base 10 numbers that uses standard place value to report the value for each digit.
 
Constructor Summary
IndexedNumber(BigInteger value)
          Initializes the value of this indexed number to the provided BigInteger.
IndexedNumber(int value)
          Initializes the value of this indexed number to the provided integer.
IndexedNumber(long value)
          Initializes the value of this indexed number to the provided long.
 
Method Summary
 int getDigit(int place)
          Returns the integer representation for the digit at the given place.
 boolean isPrefixFree()
           
 int numDigits()
           
 String printDigit(int place)
          Returns the string representation for the digit in the given place.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IndexedNumber

public IndexedNumber(int value)
Initializes the value of this indexed number to the provided integer.


IndexedNumber

public IndexedNumber(long value)
Initializes the value of this indexed number to the provided long.


IndexedNumber

public IndexedNumber(BigInteger value)
Initializes the value of this indexed number to the provided BigInteger.

Method Detail

numDigits

public int numDigits()
Returns:
the number of digits in the element

isPrefixFree

public boolean isPrefixFree()
Returns:
false since this is not a prefix free digitizer

toString

public String toString()
Overrides:
toString in class Object
Returns:
the indexed number represented as a character string

getDigit

public int getDigit(int place)
Returns the integer representation for the digit at the given place. This method treats each element as if it was padded infinitely to the left with zeros. For example, 562 can be viewed as ...000562.


printDigit

public String printDigit(int place)
Returns the string representation for the digit in the given place.