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
|
}// GEN-LAST:event_btnVersamentoActionPerformed
|
||||||
|
|
||||||
private void btnPrelievoActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_btnPrelievoActionPerformed
|
private void btnPrelievoActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_btnPrelievoActionPerformed
|
||||||
String prelievo;
|
double prelievo;
|
||||||
boolean error;
|
boolean error;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
error = false;
|
error = false;
|
||||||
prelievo = JOptionPane.showInputDialog("Inserire l'importo da prelevare:");
|
try {
|
||||||
if (!isNumeroValid(prelievo)) {
|
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.");
|
JOptionPane.showMessageDialog(null, "L'importo che si desidera prelevare non è valido.");
|
||||||
error = true;
|
error = true;
|
||||||
} else {
|
} catch (IllegalArgumentException e) {
|
||||||
try {
|
JOptionPane.showMessageDialog(null, e.getMessage());
|
||||||
contoCorrente.preleva(Double.parseDouble(prelievo));
|
error = true;
|
||||||
lblSaldoIniziale.setText("Saldo");
|
|
||||||
txtSaldoIniziale.setText(Double.toString(contoCorrente.getSaldo()));
|
|
||||||
} catch (IllegalArgumentException e) {
|
|
||||||
JOptionPane.showMessageDialog(null, e.getMessage());
|
|
||||||
error = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} while (error);
|
} while (error);
|
||||||
}// GEN-LAST:event_btnPrelievoActionPerformed
|
}// GEN-LAST:event_btnPrelievoActionPerformed
|
||||||
|
|||||||
@@ -61,15 +61,6 @@ public class MyBank {
|
|||||||
switch (scelta) {
|
switch (scelta) {
|
||||||
case 0:
|
case 0:
|
||||||
break;
|
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:
|
case 3:
|
||||||
if (conti.isEmpty()) {
|
if (conti.isEmpty()) {
|
||||||
System.out.println(ERRORE_CONTI_VUOTO);
|
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) {
|
static void stampaLog(ArrayList<ContoCorrente> conti) {
|
||||||
try (BufferedReader br = new BufferedReader(
|
try (BufferedReader br = new BufferedReader(
|
||||||
new FileReader(PATH_CONTI + "movimenti_" + selezionaConto(conti).getNumeroContoCorrente() + ".txt"))) {
|
new FileReader(PATH_CONTI + "movimenti_" + selezionaConto(conti).getNumeroContoCorrente() + ".txt"))) {
|
||||||
|
|||||||
Reference in New Issue
Block a user