com.thehackerschoice.shagg.algorithms
Class Modulus10AlgorithmCC

java.lang.Object
  |
  +--com.thehackerschoice.shagg.algorithms.Modulus10Algorithm
        |
        +--com.thehackerschoice.shagg.algorithms.Modulus10AlgorithmLuhn
              |
              +--com.thehackerschoice.shagg.algorithms.Modulus10AlgorithmCC

public class Modulus10AlgorithmCC
extends Modulus10AlgorithmLuhn

The algorithm used in Credit Cards is claimed to be the Luhn Algorithm. In fact it is a variant that uses an extra check digit that is always 0.

Version:
$Id: Modulus10AlgorithmCC.java,v 1.5 2001/12/13 13:28:25 plasmoid Exp $
Author:
Plasmoid (plasmoid@thehackerschoice.com), THC

Fields inherited from class com.thehackerschoice.shagg.algorithms.Modulus10Algorithm
type
 
Constructor Summary
Modulus10AlgorithmCC()
          Init the Modulus 10 CC Algorithm.
 
Method Summary
 boolean check(int[] sequence, int[] weights)
          Checks if the supplied sequence matches the Modulus 10 Algorithm.
 int getCheckDigitPosition(int sequence)
          Return the check digit position inside the sequence.
 int mod10checkDigit(int[] sequence)
          The result of the modulus operation is compared to 0 in all cases.
 
Methods inherited from class com.thehackerschoice.shagg.algorithms.Modulus10AlgorithmLuhn
mod10Add
 
Methods inherited from class com.thehackerschoice.shagg.algorithms.Modulus10Algorithm
getName, getSymbol, usesWeights
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Constructor Detail

Modulus10AlgorithmCC

public Modulus10AlgorithmCC()
Init the Modulus 10 CC Algorithm.
Method Detail

check

public boolean check(int[] sequence,
                     int[] weights)
Checks if the supplied sequence matches the Modulus 10 Algorithm. Modulus 10 uses the provided weights. The last digit is not used as a check digit! That's the difference to all other Modulus 10 algorithms.
Overrides:
check in class Modulus10Algorithm
Parameters:
sequence - Integer sequence representing the digits to check, not necessary between 0 and 9.
weights - Integer sequence of the weights to use, may be of any length.
Returns:
wether sequences matches the algorithm.

mod10checkDigit

public int mod10checkDigit(int[] sequence)
The result of the modulus operation is compared to 0 in all cases.
Overrides:
mod10checkDigit in class Modulus10AlgorithmLuhn
Parameters:
sequence - Integer sequence representing the digits to check, not necessary between 0 and 9.
Returns:
The check digit.

getCheckDigitPosition

public int getCheckDigitPosition(int sequence)
Return the check digit position inside the sequence. Modulus 10 uses no check digit from the given sequence.
Overrides:
getCheckDigitPosition in class Modulus10Algorithm
Parameters:
sequence - Length of the integer sequence representing the digits to check, not necessary between 0 and 9.
Returns:
Position of the check digit.