Prelievo (quello prima era versamento)
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -308,24 +308,23 @@ public class GUIMyBank extends javax.swing.JFrame {
|
||||
}// GEN-LAST:event_btnVersamentoActionPerformed
|
||||
|
||||
private void btnPrelievoActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_btnPrelievoActionPerformed
|
||||
String prelievo;
|
||||
double prelievo;
|
||||
boolean error;
|
||||
|
||||
do {
|
||||
error = false;
|
||||
prelievo = JOptionPane.showInputDialog("Inserire l'importo da prelevare:");
|
||||
if (!isNumeroValid(prelievo)) {
|
||||
try {
|
||||
prelievo = MyBank.valoreDouble(JOptionPane.showInputDialog("Inserire l'importo da versare:"));
|
||||
|
||||
contoCorrenteAperto.preleva(prelievo);
|
||||
lblSaldoIniziale.setText("Saldo");
|
||||
txtSaldoIniziale.setText(Double.toString(contoCorrenteAperto.getSaldo()));
|
||||
} catch (NumberFormatException _) {
|
||||
JOptionPane.showMessageDialog(null, "L'importo che si desidera prelevare non è valido.");
|
||||
error = true;
|
||||
} else {
|
||||
try {
|
||||
contoCorrente.preleva(Double.parseDouble(prelievo));
|
||||
lblSaldoIniziale.setText("Saldo");
|
||||
txtSaldoIniziale.setText(Double.toString(contoCorrente.getSaldo()));
|
||||
} catch (IllegalArgumentException e) {
|
||||
JOptionPane.showMessageDialog(null, e.getMessage());
|
||||
error = true;
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
JOptionPane.showMessageDialog(null, e.getMessage());
|
||||
error = true;
|
||||
}
|
||||
} while (error);
|
||||
}// GEN-LAST:event_btnPrelievoActionPerformed
|
||||
|
||||
@@ -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"))) {
|
||||
|
||||
Reference in New Issue
Block a user