-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConta.java
More file actions
47 lines (38 loc) · 1.03 KB
/
Conta.java
File metadata and controls
47 lines (38 loc) · 1.03 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
46
47
public abstract class Conta {
protected int agencia;
protected int numero;
protected double saldo;
protected Cliente titular;
public Conta(int agencia, int numero, Cliente titular) {
this.agencia = agencia;
this.numero = numero;
this.titular = titular;
this.saldo = 0.0;
}
public void sacar(double valor) {
saldo -= valor;
}
public void depositar(double valor) {
saldo += valor;
}
public void transferir(double valor, Conta destino) {
this.sacar(valor);
destino.depositar(valor);
}
public int getAgencia() {
return agencia;
}
public int getNumero() {
return numero;
}
public double getSaldo() {
return saldo;
}
protected void imprimirInfosComuns() {
System.out.println("Titular: " + titular.getNome());
System.out.println("Agência: " + agencia);
System.out.println("Número: " + numero);
System.out.printf("Saldo: R$ %.2f\n", saldo);
}
public abstract void imprimirExtrato();
}