Versamento

This commit is contained in:
La Programmatrice Verde
2026-02-17 18:15:51 +01:00
parent f0e0d493d0
commit c3a3c11c66
9 changed files with 33 additions and 0 deletions

Binary file not shown.

View File

@@ -4,10 +4,38 @@
*/
package guimybank;
import java.util.ArrayList;
/**
*
* @author Verde
*/
public class ContoCorrente {
private String nome;
private String cognome;
private String codiceFiscale;
private double saldo;
private int numeroContoCorrente;
//private Date dataDiNascita;
public ContoCorrente(String nome, String cognome, String codiceFiscale, /*Date dataDiNascita,*/ double saldo) {
this.nome = nome;
this.cognome = cognome;
this.codiceFiscale = codiceFiscale;
//this.dataDiNascita = dataDiNascita;
this.saldo = saldo;
}
public void versa(double quantita){
this.saldo += quantita;
}
public void preleva(double quantita) throws IllegalArgumentException{
if (quantita > this.saldo) {
throw new IllegalArgumentException("La quantità desiderata eccede il saldo corrente.");
}
else {
this.saldo -= quantita;
}
}
}

View File

@@ -20,6 +20,7 @@ import javax.swing.border.LineBorder;
public class GUIMyBank extends javax.swing.JFrame {
static Border borderOriginale = UIManager.getBorder("TextField.border");
static ContoCorrente contoCorrente;
private static final java.util.logging.Logger logger = java.util.logging.Logger
.getLogger(GUIMyBank.class.getName());
@@ -219,6 +220,8 @@ txtCognome.setBorder(borderOriginale);
if (!isNumeroValid(versamento)) {
JOptionPane.showMessageDialog(null, "L'importo che si desidera versare non è valido.");
error = true;
} else {
contoCorrente.versa(Double.parseDouble(versamento));
}
} while (error);
}//GEN-LAST:event_btnVersamentoActionPerformed
@@ -272,6 +275,8 @@ txtCognome.setBorder(borderOriginale);
return;
}
contoCorrente = new ContoCorrente(nome, cognome, codiceFiscale, Double.parseDouble(saldoIniziale));
btnVersamento.setVisible(true);
btnPrelievo.setVisible(true);
btnListaMovimenti.setVisible(true);