Versamento
This commit is contained in:
BIN
build/classes/guimybank/ContoCorrente.class
Normal file
BIN
build/classes/guimybank/ContoCorrente.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user