Prelievo (quello prima era versamento)

This commit is contained in:
La Programmatrice Verde
2026-03-03 11:26:17 +01:00
parent 884fe890c6
commit 5504dfd91c
4 changed files with 11 additions and 68 deletions

View File

@@ -61,15 +61,6 @@ public class MyBank {
switch (scelta) {
case 0:
break;
case 2:
if (conti.isEmpty()) {
System.out.println(ERRORE_CONTI_VUOTO);
} else {
versa(conti);
System.out.println("Versamento effettuato con successo.");
}
pausa();
break;
case 3:
if (conti.isEmpty()) {
System.out.println(ERRORE_CONTI_VUOTO);
@@ -203,53 +194,6 @@ public class MyBank {
}
}
static void versa(ArrayList<ContoCorrente> conti) {
selezionaConto(conti).versa(quantita("da versare"));
}
static void preleva(ArrayList<ContoCorrente> conti) {
boolean error;
do {
error = false;
try {
selezionaConto(conti).preleva(quantita("da prelevare"));
} catch (IllegalArgumentException e) {
System.out.println(e.getMessage());
pausa();
error = true;
}
} while (error);
}
static ContoCorrente selezionaConto(ArrayList<ContoCorrente> conti) {
ContoCorrente contoCorrente = null;
int numeroContoCorrente;
boolean error;
do {
error = false;
System.out.print("Inserire il proprio numero di conto: ");
numeroContoCorrente = sc.nextInt();
sc.nextLine();
if (!ContoCorrente.getNumeriContiCorrenti().contains(numeroContoCorrente)) {
System.out.println("Errore: il conto corrente specificato non esiste.");
pausa();
error = true;
} else {
for (ContoCorrente conto : conti) {
if (conto.getNumeroContoCorrente() == numeroContoCorrente) {
contoCorrente = conto;
break;
}
}
}
} while (error);
return contoCorrente;
}
static void stampaLog(ArrayList<ContoCorrente> conti) {
try (BufferedReader br = new BufferedReader(
new FileReader(PATH_CONTI + "movimenti_" + selezionaConto(conti).getNumeroContoCorrente() + ".txt"))) {