File tree 2 files changed +19
-1
lines changed 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -40,7 +40,12 @@ public double GetSaldo() {
40
40
* @param valor
41
41
*/
42
42
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
+ }
44
49
45
50
}
46
51
@@ -62,4 +67,15 @@ public String getNumero() {
62
67
return this .numero ;
63
68
}
64
69
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
+
65
81
}
Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ public static void main(String[] args) {
20
20
System .out .println ("Nome: " + cli .getNome () + " Numero Agencia: " + cli .getConta ().get (0 ).getNumero ());
21
21
cli .addConta (conta1 );
22
22
System .out .println ("Nome: " + cli .getNome () + " Numero Agencia: " + cli .getConta ().get (1 ).getNumero ());
23
+ conta1 .depositar (20 );
24
+ conta1 .sacar (20 );
23
25
}
24
26
25
27
}
You can’t perform that action at this time.
0 commit comments