Migliore gestione conto corrente esistente
This commit is contained in:
@@ -35,6 +35,7 @@ public class MyBank {
|
||||
static final String ERRORE_GENERICO = "Errore: opzione non valida.";
|
||||
static final String ERRORE_CONTI_VUOTO = "Errore: è necessario aggiungere almeno un conto corrente prima di proseguire.";
|
||||
public static final String PATH_CONTI = "./src/logic/conti/";
|
||||
static final String FORMATO_DATA = "dd/MM/yyyy";
|
||||
private static ArrayList<ContoCorrente> conti;
|
||||
|
||||
public static void setConti(ArrayList<ContoCorrente> conti) {
|
||||
@@ -49,7 +50,7 @@ public class MyBank {
|
||||
ArrayList<ContoCorrente> conti = new ArrayList<>();
|
||||
File percorsoConti = new File(PATH_CONTI);
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.setDateFormat(new SimpleDateFormat("dd/MM/yyyy"));
|
||||
mapper.setDateFormat(new SimpleDateFormat(FORMATO_DATA));
|
||||
StringBuilder sb;
|
||||
String riga;
|
||||
|
||||
@@ -80,11 +81,12 @@ public class MyBank {
|
||||
return conti;
|
||||
}
|
||||
|
||||
public static ContoCorrente aggiungiConto(String nome, String cognome, String codiceFiscale, Date dataDiNascita,
|
||||
public static ContoCorrenteWrapper aggiungiConto(String nome, String cognome, String codiceFiscale, Date dataDiNascita,
|
||||
double saldoIniziale) throws IOException{
|
||||
int numeroContoCorrente;
|
||||
ContoCorrente contoCorrente;
|
||||
boolean exit = false;
|
||||
boolean isImported;
|
||||
int i = 0;
|
||||
|
||||
numeroContoCorrente = Math.abs(codiceFiscale.hashCode());
|
||||
@@ -94,6 +96,7 @@ public class MyBank {
|
||||
exit = conti.get(i).getNumeroContoCorrente() == numeroContoCorrente;
|
||||
}
|
||||
contoCorrente = conti.get(i);
|
||||
isImported = true;
|
||||
} else {
|
||||
File percorsoConti = new File(PATH_CONTI);
|
||||
if (!percorsoConti.exists()) {
|
||||
@@ -103,9 +106,10 @@ public class MyBank {
|
||||
numeroContoCorrente);
|
||||
conti.add(contoCorrente);
|
||||
salvaContoCorrente(contoCorrente);
|
||||
isImported = false;
|
||||
}
|
||||
|
||||
return contoCorrente;
|
||||
return new ContoCorrenteWrapper(contoCorrente, isImported);
|
||||
}
|
||||
|
||||
public static boolean isCodiceFiscaleValid(String codiceFiscale) {
|
||||
@@ -114,12 +118,17 @@ public class MyBank {
|
||||
}
|
||||
|
||||
public static Date dataDiNascita(String dataDiNascita) throws ParseException {
|
||||
final String FORMATO_DATA = "dd/MM/yyyy";
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(FORMATO_DATA);
|
||||
sdf.setLenient(false);
|
||||
return sdf.parse(dataDiNascita);
|
||||
}
|
||||
|
||||
public static String dataDiNascita(Date dataDiNascita) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(FORMATO_DATA);
|
||||
sdf.setLenient(false);
|
||||
return sdf.format(dataDiNascita);
|
||||
}
|
||||
|
||||
public static double valoreDouble(String numeroDouble) throws NumberFormatException {
|
||||
double valoreDouble;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user