Lettura numeriContiCorrenti + modifica log
This commit is contained in:
@@ -22,8 +22,6 @@ public class ContoCorrente {
|
|||||||
|
|
||||||
private static ArrayList<Integer> numeriContiCorrenti = new ArrayList<>();
|
private static ArrayList<Integer> numeriContiCorrenti = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public ContoCorrente(String nome, String cognome, String codiceFiscale, Date dataDiNascita, double saldo,
|
public ContoCorrente(String nome, String cognome, String codiceFiscale, Date dataDiNascita, double saldo,
|
||||||
int numeroContoCorrente) {
|
int numeroContoCorrente) {
|
||||||
this.nome = nome;
|
this.nome = nome;
|
||||||
@@ -40,6 +38,10 @@ public class ContoCorrente {
|
|||||||
return numeriContiCorrenti;
|
return numeriContiCorrenti;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setNumeriContiCorrenti(List<Integer> numeriContiCorrenti) {
|
||||||
|
ContoCorrente.numeriContiCorrenti = (ArrayList<Integer>)numeriContiCorrenti;
|
||||||
|
}
|
||||||
|
|
||||||
public int getNumeroContoCorrente() {
|
public int getNumeroContoCorrente() {
|
||||||
return numeroContoCorrente;
|
return numeroContoCorrente;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,12 +87,12 @@ public class MyBank {
|
|||||||
pausa();
|
pausa();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
System.out.println("Opzione non valida.");
|
System.out.println(ERRORE_GENERICO);
|
||||||
pausa();
|
pausa();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (InputMismatchException _) {
|
} catch (InputMismatchException _) {
|
||||||
System.out.println("Errore: scelta non valida.");
|
System.out.println(ERRORE_GENERICO);
|
||||||
pausa();
|
pausa();
|
||||||
}
|
}
|
||||||
} while (scelta != 0);
|
} while (scelta != 0);
|
||||||
@@ -110,13 +110,15 @@ public class MyBank {
|
|||||||
|
|
||||||
if (percorsoConti.exists() && percorsoConti.listFiles().length != 0) {
|
if (percorsoConti.exists() && percorsoConti.listFiles().length != 0) {
|
||||||
for (File conto : percorsoConti.listFiles()) {
|
for (File conto : percorsoConti.listFiles()) {
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
if (conto.getName().substring(conto.getName().lastIndexOf(".")).equals("json")) {
|
if (conto.getName().substring(conto.getName().lastIndexOf(".")).equals("json")) {
|
||||||
try (BufferedReader bf = new BufferedReader(new FileReader(conto))) {
|
try (BufferedReader bf = new BufferedReader(new FileReader(conto))) {
|
||||||
for (String rigaJSON : bf.readAllLines()) {
|
|
||||||
sb.append(rigaJSON);
|
conti.add(mapper.readValue(bf.readAllAsString(), ContoCorrente.class));
|
||||||
}
|
|
||||||
conti.add(mapper.readValue(sb.toString(), ContoCorrente.class));
|
ArrayList<Integer> numeriContiCorrenti = (ArrayList<Integer>) ContoCorrente.getNumeriContiCorrenti();
|
||||||
|
numeriContiCorrenti.add(conti.getLast().getNumeroContoCorrente());
|
||||||
|
ContoCorrente.setNumeriContiCorrenti(numeriContiCorrenti);
|
||||||
|
|
||||||
} catch (Exception _) {
|
} catch (Exception _) {
|
||||||
System.out.println("Errore nella lettura del file di conto corrente.");
|
System.out.println("Errore nella lettura del file di conto corrente.");
|
||||||
}
|
}
|
||||||
@@ -297,7 +299,7 @@ public class MyBank {
|
|||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss.sss dd/MM/yyyy");
|
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss.sss dd/MM/yyyy");
|
||||||
try (BufferedWriter bw = new BufferedWriter(
|
try (BufferedWriter bw = new BufferedWriter(
|
||||||
new FileWriter(PATH_CONTI + "movimenti_" + numeroContoCorrente + ".txt"))) {
|
new FileWriter(PATH_CONTI + "movimenti_" + numeroContoCorrente + ".txt", true))) {
|
||||||
sb.append("[");
|
sb.append("[");
|
||||||
sb.append(sdf.format(new Date()));
|
sb.append(sdf.format(new Date()));
|
||||||
sb.append("] ");
|
sb.append("] ");
|
||||||
|
|||||||
Reference in New Issue
Block a user