Main (TesteExceptions.java:14):
Conta c1 = new ContaCorrente(444, 444);
c1.setSaldo(5000);
Conta c2 = new ContaCorrente(444, 445);
c2.setSaldo(353);
System.out.println(c1.getSaldo() + "\n" + c2.getSaldo());
c1.transfere(c2, 1);
System.out.println(c1.getSaldo() + "\n" + c2.getSaldo());
Método transfere (Conta.java:22):
public void transfere(Conta destino, double valor){
if (this.getSaldo() >= valor) {
if (this != destino) {
this.saca(valor);
destino.deposita(valor);
}
throw new AccountException("you can not make transfers to your own account");
}
}
Método saca (ContaCorrente.java:25):
@Override
public void saca(double valor) {
if (this.getSaldo() >= valor) {
super.setSaldo(super.getSaldo() - valor - this.taxa);
}
throw new BalanceException("you tried to withdraw a higher amount than the balance in your account");
}
5000.0 353.0 Exception in thread "main" br.com...exceptions.BalanceException: you tried to withdraw a higher amount than the balance in your account at br.com...ContaCorrente.saca(ContaCorrente.java:25) at br.com...Conta.transfere(Conta.java:22) at br.com...TesteExceptions.main(TesteExceptions.java:14)
O que estou fazendo de errado?
double
para valor monetário.