Olá… pessoal! Como faço para alterar os valores desse class e garantir que elle aceite números letras menores e difrentes dos especificados? Por exemplo: no lugar do ISBN “85-08-03543-8” quero dar entrada para o registro “01A”.
Um abraço a todos… segue o code…
=========
public class ISBN
{
public ISBN()
{
}
public static boolean check(String isbn)
{
char theChars[] = isbn.toUpperCase().toCharArray();
int checksum = 0;
int weight = 10;
int i;
for(i = 0; i < theChars.length && weight > 0; i++)
{
int val = "0123456789X-".indexOf(theChars[i]);
if(val >= 0)
{
if(val == 10 && weight != 1)
return false;
if(val < 11)
{
checksum += weight * val;
weight--;
}
} else
{
return false;
}
}
if(i < theChars.length)
return false;
else
return checksum % 11 == 0;
}
public static void main(String args[])
{
System.out.println(check("0-8436-1072-7"));
System.out.println(check("0-8436-1072-X"));
System.out.println(check("0-8436-1077-X"));
System.out.println(check("0-8436-x072-7"));
System.out.println(check(" 0843610727"));
System.out.println(check("x0843610727"));
System.out.println(check("08436107278"));
}
private static final String NUMVALUES = "0123456789X-";
}
===============