rimuoviCarattere
This commit is contained in:
parent
f24c58190e
commit
bac72b74e9
@ -6,21 +6,38 @@ package appComune;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import utility.GestisciStringhe;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Verde
|
||||
*/
|
||||
public class GestisciCodiceFiscale {
|
||||
|
||||
static final String[] CARATTERI_DA_RIMUOVERE = { " ", "'", "`" };
|
||||
|
||||
public static String CalcolaCodiceFiscale(String nome, String cognome, Date dataNascita, String luogo,
|
||||
String sesso) {
|
||||
|
||||
}
|
||||
|
||||
static String CalcolaPrimaTerna(String cognome){
|
||||
for (String carattere : CARATTERI_DA_RIMUOVERE) {
|
||||
cognome = GestisciStringhe.rimuoviCarattere(cognome, carattere);
|
||||
}
|
||||
|
||||
cognome = cognome.toLowerCase();
|
||||
|
||||
|
||||
}
|
||||
|
||||
static String CalcolaSecondaTerna(String nome) {
|
||||
for (String carattere : CARATTERI_DA_RIMUOVERE) {
|
||||
nome = GestisciStringhe.rimuoviCarattere(nome, carattere);
|
||||
}
|
||||
|
||||
nome = nome.toLowerCase();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -4,6 +4,9 @@
|
||||
*/
|
||||
package utility;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Verde
|
||||
@ -38,6 +41,18 @@ public class GestisciStringhe {
|
||||
}
|
||||
|
||||
public static String rimuoviCarattere(String testo, String carattere) {
|
||||
char[] testoOriginale = testo.toCharArray();
|
||||
LinkedList<Character> testoRipulito = new LinkedList<>();
|
||||
String ritorno;
|
||||
|
||||
for (int i = 0; i < testoOriginale.length; i++) {
|
||||
if (testoOriginale[i] != carattere.toCharArray()[0]) {
|
||||
testoRipulito.add(testoOriginale[i]);
|
||||
}
|
||||
}
|
||||
|
||||
ritorno = Arrays.toString(testoRipulito.toArray());
|
||||
|
||||
return ritorno;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user