Skip to content

Commit 743078c

Browse files
authored
Merge pull request #4 from stanley-java-projects/checkSaldo
adicionado metodo checarSaldo
2 parents 240858c + 6ac3cc9 commit 743078c

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/model/Conta.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ public double GetSaldo() {
4040
* @param valor
4141
*/
4242
public void sacar(double valor) {
43-
this.saldo = this.saldo - valor;
43+
if (this.checaSaldo(valor)) {
44+
this.saldo = this.saldo - valor;
45+
System.out.println("Saldo suficiente! Saldo atual:" + this.saldo);
46+
}else {
47+
System.out.println("Saldo insuficiente.");
48+
}
4449

4550
}
4651

@@ -62,4 +67,15 @@ public String getNumero() {
6267
return this.numero;
6368
}
6469

70+
/**
71+
* Metodo de checagem de saldo
72+
*/
73+
74+
public boolean checaSaldo(double saque) {
75+
if (this.saldo >= saque) {
76+
return true;
77+
}
78+
return false;
79+
}
80+
6581
}

src/view/App.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public static void main(String[] args) {
2020
System.out.println("Nome: " + cli.getNome() + " Numero Agencia: " + cli.getConta().get(0).getNumero());
2121
cli.addConta(conta1);
2222
System.out.println("Nome: " + cli.getNome() + " Numero Agencia: " + cli.getConta().get(1).getNumero());
23+
conta1.depositar(20);
24+
conta1.sacar(20);
2325
}
2426

2527
}

0 commit comments

Comments
 (0)