Gestione codice fiscale + numeroContoCorrente
This commit is contained in:
@@ -15,6 +15,7 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.InputMismatchException;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -132,10 +133,8 @@ public class MyBank {
|
||||
numeriContiCorrenti.add(conti.getLast().getNumeroContoCorrente());
|
||||
ContoCorrente.setNumeriContiCorrenti(numeriContiCorrenti);
|
||||
|
||||
} catch (Exception e) {
|
||||
} catch (Exception _) {
|
||||
System.out.println("Errore nella lettura del file di conto corrente.");
|
||||
System.out.println(e.getMessage());
|
||||
System.out.println(e.getStackTrace());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -144,32 +143,35 @@ public class MyBank {
|
||||
}
|
||||
|
||||
static void aggiungiConto(ArrayList<ContoCorrente> conti) {
|
||||
double saldoIniziale;
|
||||
int numeroContoCorrente;
|
||||
Persona persona = persona();
|
||||
Persona persona;
|
||||
boolean error;
|
||||
ContoCorrente contoCorrente;
|
||||
List<String> listaCodiciFiscali;
|
||||
|
||||
do {
|
||||
error = false;
|
||||
|
||||
saldoIniziale = quantita("del saldo iniziale");
|
||||
try {
|
||||
persona = persona();
|
||||
listaCodiciFiscali = ScriviLeggiFile.leggiCodiciFiscali();
|
||||
|
||||
numeroContoCorrente = Math.abs(persona.getCodiceFiscale().hashCode());
|
||||
|
||||
if (ContoCorrente.getNumeriContiCorrenti().contains(numeroContoCorrente)) {
|
||||
System.out.println("Errore: esiste già un conto corrente per questo codice fiscale, riprovare.");
|
||||
pausa();
|
||||
error = true;
|
||||
} else {
|
||||
File percorsoConti = new File(PATH_CONTI);
|
||||
if (!percorsoConti.exists()) {
|
||||
percorsoConti.mkdir();
|
||||
if (listaCodiciFiscali != null && listaCodiciFiscali.contains(persona.getCodiceFiscale())) {
|
||||
System.out.println("Errore: esiste già un conto corrente per questo codice fiscale, riprovare.");
|
||||
pausa();
|
||||
error = true;
|
||||
} else {
|
||||
ScriviLeggiFile.salvaCodiceFiscale(persona.getCodiceFiscale());
|
||||
File percorsoConti = new File(PATH_CONTI);
|
||||
if (!percorsoConti.exists()) {
|
||||
percorsoConti.mkdir();
|
||||
}
|
||||
contoCorrente = new ContoCorrente(persona, quantita("del saldo iniziale"));
|
||||
conti.add(contoCorrente);
|
||||
salvaContoCorrente(contoCorrente);
|
||||
}
|
||||
contoCorrente = new ContoCorrente(persona, saldoIniziale,
|
||||
numeroContoCorrente);
|
||||
conti.add(contoCorrente);
|
||||
salvaContoCorrente(contoCorrente);
|
||||
} catch (IOException e) {
|
||||
System.out.println(e.getMessage());
|
||||
error = true;
|
||||
}
|
||||
} while (error);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user