Compte.java 836 Bytes


public class Compte {
     double credit = 0;
     double debit = 0;

    public double getCredit(){
        return this.credit;
    }
    
     public double getDebit(){
        return this.debit;
    }
    
    public void setCredit(double x){
        this.credit = x;
    }
    
    public void setDebit(double x){
       this.debit = x;
    }
    
    public Compte(){
    
    }
    
    public Compte(double val){
       setCredit(val);
    }
    
    public void crediter(double val){
        setCredit(getCredit()+val);
    }
    
    public void debiter(double val){
        setDebit(getDebit()+val);
    }
    
    public double solde(){
        return (getCredit()-getDebit());
    }
    
    public String toString(){
        return "Votre solde actuel est de "+solde()+" ("+getCredit()+" - "+getDebit()+")";
    }
    
}