-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConta.java
More file actions
45 lines (36 loc) · 1.12 KB
/
Conta.java
File metadata and controls
45 lines (36 loc) · 1.12 KB
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
37
38
39
40
41
42
43
44
45
package banco;
public abstract class Conta {
protected int numero;
protected String cliente;
protected double saldo;
public Conta(int numero, String cliente) {
this.numero = numero;
this.cliente = cliente;
this.saldo = 0.0;
}
public int getNumero() {
return numero;
}
public String getCliente() {
return cliente;
}
public double getSaldo() {
return saldo;
}
public void depositar(double valor) {
if (valor > 0) {
saldo += valor;
System.out.println("Depósito realizado com sucesso!");
} else {
System.out.println("Valor inválido!");
}
}
// Métodos abstratos -> cada tipo de conta implementa do seu jeito
public abstract boolean sacar(double valor);
public abstract boolean transferir(Conta destino, double valor);
@Override
public String toString() {
return "Conta Nº: " + numero + " | Cliente: " + cliente +
" | Saldo: R$ " + saldo + " | Tipo: " + this.getClass().getSimpleName();
}
}