Skip to content

Commit

Permalink
style: Geracao de DV do titulo de eleitor
Browse files Browse the repository at this point in the history
  • Loading branch information
tnas committed Nov 5, 2024
1 parent 3e8278d commit 3ecb770
Showing 1 changed file with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,24 +179,28 @@ private String calculaDigitos(String tituloSemDigito) {
return digito1 + digito2;
}

private String geraDigito(boolean ehEstadoSubstitutorDigito, String base) {
private String geraDigito(boolean ehEstadoSubstitutorDigito, String base) {

String digito = new DigitoPara(base).mod(11).calcula();

if (ehEstadoSubstitutorDigito) {
if (digito.equals("1")) {
digito = "0";
} else if (digito.equals("0")) {
digito = "1";
} else {
digito = new DigitoPara(base).complementarAoModulo().mod(11).calcula();
if (!ehEstadoSubstitutorDigito) {

if (digito.equals("1") || digito.equals("0")) {
return "0";
}
} else {
digito = digito.equals("1") || digito.equals("0") ? "0" :
new DigitoPara(base).complementarAoModulo().mod(11).calcula();
}

return new DigitoPara(base).complementarAoModulo().mod(11).calcula();
}

return digito;
if (digito.equals("1")) {
return "0";
}

if (digito.equals("0")) {
return "1";
}

return new DigitoPara(base).complementarAoModulo().mod(11).calcula();
}

private boolean hasCodigoDeEstadoInvalido(String tituloDeEleitor) {
Expand Down

0 comments on commit 3ecb770

Please sign in to comment.