Opzione 3
This commit is contained in:
@@ -17,18 +17,20 @@ public class ContoCorrente {
|
||||
private String cognome;
|
||||
private String codiceFiscale;
|
||||
private Date dataDiNascita;
|
||||
private double saldoIniziale;
|
||||
private double saldo;
|
||||
private int numeroContoCorrente;
|
||||
|
||||
private static ArrayList<Integer> numeriContiCorrenti = new ArrayList<>();
|
||||
|
||||
public ContoCorrente(String nome, String cognome, String codiceFiscale, Date dataDiNascita, double saldoIniziale,
|
||||
|
||||
|
||||
public ContoCorrente(String nome, String cognome, String codiceFiscale, Date dataDiNascita, double saldo,
|
||||
int numeroContoCorrente) {
|
||||
this.nome = nome;
|
||||
this.cognome = cognome;
|
||||
this.codiceFiscale = codiceFiscale;
|
||||
this.dataDiNascita = dataDiNascita;
|
||||
this.saldoIniziale = saldoIniziale;
|
||||
this.saldo = saldo;
|
||||
this.numeroContoCorrente = numeroContoCorrente;
|
||||
numeriContiCorrenti.add(numeroContoCorrente);
|
||||
}
|
||||
@@ -40,4 +42,13 @@ public class ContoCorrente {
|
||||
public int getNumeroContoCorrente() {
|
||||
return numeroContoCorrente;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user