public class CompteEnBanque {
	private Personne titulaire;
	private String numero, code, type;
	private double solde, limite, txInteret;
	public CompteEnBanque(String n, String c, Personne t, 
			String ty, double s, double l, double tx){
		numero = n;
		this.code = c;
		this.titulaire = t;
		type = ty;
		solde = s;
		limite = l;
		txInteret = tx;
	}
	public CompteEnBanque(String n, Personne t){
		this(n,"0000",t,"Courant",0,0,0.02);
	}
	public double getSolde(){
		return solde;
	}
	public String getNumero(){
		return numero;
	}
	public void setTxInteret(double nouveauTaux){
		this.txInteret = nouveauTaux;
	}
	public void setTitulaire(Personne titu){
		this.titulaire = titu;
	}
	public boolean depot(double montant){
		if(montant>0){
			this.solde+=montant;
			System.out.println("Je suis un compte et j'ai reçu un dépôt de "+montant);
			return true;
		} else
			return false;
	}
	public boolean retrait(double montant){
		if(montant>0 && montant<=(this.solde+this.limite)){
			this.solde-=montant;
			System.out.println("Je suis un compte et j'ai acté un retrait de "+montant);
			return true;
		} else{
			System.out.println("Je suis un compte et j'ai refusé un dépôt de "+montant);
			return false;
		}
	}
	public void calculInteret(){
		this.solde*=(1+this.txInteret);
		System.out.println("Je suis un compte et j'ai calculé mes intérêts... Trop fort!");
	}
	public String afficheToi(){
		String s = "Je suis le compte n°"+this.numero+
		" de M. "+this.titulaire.getNom()+
		" et mon solde est de "+this.solde;
		System.out.println(s);
		return s;
	}
	public boolean virement(double montant,CompteEnBanque b){
		System.out.println("Bon, j'essaie le virement...");
		if(this.retrait(montant) && b.depot(montant))
			return true;
		else
			return false;
	}
}
