cnrg.itx.ds
Class Digits

java.lang.Object
  |
  +--cnrg.itx.ds.Digits

public class Digits
extends java.lang.Object
implements java.io.Serializable

This class provides an abstraction to digits

See Also:
Serialized Form

Constructor Summary
Digits(int num)
          Constructor for integer.
Digits(int[] n)
          Constructor for integer array
Digits(java.lang.String num)
          Constructor for string of digits.
 
Method Summary
 int count()
          Count the number of digits in this digits object
 boolean equals(Digits digits)
          Compare with other digits instance to determine if they are identical
 int[] getArray()
          Returns itself represented as an array of int
 int getValue()
          Get the digits value
 java.lang.String toString()
          Returns itself represented as a string
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Digits

public Digits(java.lang.String num)
Constructor for string of digits. The constructor does nothing if the input string is not in digits form.
Parameters:
num - string of digits

Digits

public Digits(int num)
Constructor for integer. The constructor does nothing if the input integer is less than 1.
Parameters:
num - integer value

Digits

public Digits(int[] n)
Constructor for integer array
Parameters:
n - array of int
Method Detail

getValue

public int getValue()
Get the digits value
Returns:
integer value of this Digits object

count

public int count()
Count the number of digits in this digits object
Returns:
the number of digits in this object

getArray

public int[] getArray()
Returns itself represented as an array of int
Returns:
array of int

toString

public java.lang.String toString()
Returns itself represented as a string
Returns:
string of digits
Overrides:
toString in class java.lang.Object

equals

public boolean equals(Digits digits)
Compare with other digits instance to determine if they are identical
Parameters:
digits - another digits object to be compared
Returns:
true if identical; false otherwise