Correzioni
This commit is contained in:
@@ -8,6 +8,8 @@ import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Verde
|
||||
@@ -16,12 +18,18 @@ public class ContoCorrente {
|
||||
private String nome;
|
||||
private String cognome;
|
||||
private String codiceFiscale;
|
||||
private Date dataDiNascita;
|
||||
private double saldo;
|
||||
private int numeroContoCorrente;
|
||||
|
||||
private static ArrayList<Integer> numeriContiCorrenti = new ArrayList<>();
|
||||
|
||||
@JsonFormat
|
||||
(shape = JsonFormat.Shape.STRING, pattern = "dd/MM/yyyy")
|
||||
private Date dataDiNascita;
|
||||
|
||||
public ContoCorrente() {
|
||||
}
|
||||
|
||||
public ContoCorrente(String nome, String cognome, String codiceFiscale, Date dataDiNascita, double saldo,
|
||||
int numeroContoCorrente) {
|
||||
this.nome = nome;
|
||||
@@ -48,17 +56,43 @@ public class ContoCorrente {
|
||||
|
||||
public void versa(double quantita){
|
||||
this.saldo += quantita;
|
||||
MyBank.log("Versamento di " + quantita + " effettuato con successo.\nSaldo corrente: " + this.saldo, this.numeroContoCorrente);
|
||||
MyBank.log("Versamento di " + quantita + " effettuato con successo.", this.numeroContoCorrente);
|
||||
logSaldoCorrente();
|
||||
}
|
||||
|
||||
public void preleva(double quantita) throws IllegalArgumentException{
|
||||
if (quantita >= this.saldo) {
|
||||
MyBank.log("Tentato prelievo di " + quantita + " fallito per superamento saldo.\nSaldo corrente: " + this.saldo, this.numeroContoCorrente);
|
||||
if (quantita > this.saldo) {
|
||||
MyBank.log("Tentato prelievo di " + quantita + " fallito per superamento saldo.", this.numeroContoCorrente);
|
||||
logSaldoCorrente();
|
||||
throw new IllegalArgumentException("La quantità desiderata eccede il saldo corrente.");
|
||||
}
|
||||
else {
|
||||
this.saldo -= quantita;
|
||||
MyBank.log("Prelievo di " + quantita + " effettuato con successo.\nSaldo corrente: " + this.saldo, this.numeroContoCorrente);
|
||||
MyBank.log("Prelievo di " + quantita + " effettuato con successo.", this.numeroContoCorrente);
|
||||
logSaldoCorrente();
|
||||
}
|
||||
}
|
||||
|
||||
private void logSaldoCorrente() {
|
||||
MyBank.log("Saldo corrente: " + this.saldo + "\n", this.numeroContoCorrente);
|
||||
}
|
||||
public String getNome() {
|
||||
return nome;
|
||||
}
|
||||
|
||||
public String getCognome() {
|
||||
return cognome;
|
||||
}
|
||||
|
||||
public String getCodiceFiscale() {
|
||||
return codiceFiscale;
|
||||
}
|
||||
|
||||
public Date getDataDiNascita() {
|
||||
return dataDiNascita;
|
||||
}
|
||||
|
||||
public double getSaldo() {
|
||||
return saldo;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user