-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContaCorrente.java
More file actions
36 lines (31 loc) · 979 Bytes
/
Copy pathContaCorrente.java
File metadata and controls
36 lines (31 loc) · 979 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package banco;
public class ContaCorrente extends Conta implements ITributavel {
public ContaCorrente(int numero, String cliente) {
super(numero, cliente);
}
@Override
public boolean sacar(double valor) {
double taxa = valor * 0.05;
double total = valor + taxa;
if (saldo >= total) {
saldo -= total;
System.out.println("Saque realizado com taxa de 5%. Valor sacado: " + valor);
return true;
}
System.out.println("Saldo insuficiente!");
return false;
}
@Override
public boolean transferir(Conta destino, double valor) {
if (this.sacar(valor)) {
destino.depositar(valor);
System.out.println("Transferência realizada!");
return true;
}
return false;
}
@Override
public double calculaTributos() {
return saldo * 0.01; // 1% do saldo
}
}