-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExer02.java
More file actions
141 lines (115 loc) · 4.03 KB
/
Exer02.java
File metadata and controls
141 lines (115 loc) · 4.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
package com.leandro.aula27.labs;
import java.util.Scanner;
public class Exer02 {
static ContaCorrente cliente1 = new ContaCorrente();
static Scanner scan = new Scanner(System.in);
public static void main(String[] args) {
cliente1.cc = 37244;
cliente1.ag = 258;
cliente1.saldo = 2000;
cliente1.limite = 1000;
cliente1.especial = true;
int opcao = menuBanco();
if (opcao == 1) {
double total = 0;
System.out.println("Digite a quantia que quer sacar.");
double quantiaPedidoSaque = scan.nextDouble();
boolean pedidoSaque = cliente1.estadoParaSaque(quantiaPedidoSaque);
if (pedidoSaque) {
total = cliente1.sacarDinheiro(quantiaPedidoSaque);
} else {
System.out.println("Você não tem saldo e/ou limite suficiente"
+ " para efetuar este saque.");
cliente1.consultarSaldo();
}
retornaAoMenu();
}
if (opcao == 2) {
cliente1.consultarSaldo();
retornaAoMenu();
}
if (opcao == 3) {
cliente1.depositarConta();
retornaAoMenu();
}
if (opcao == 4) {
cliente1.consultarChequeEspecial();
retornaAoMenu();
}
if (opcao == 5) {
System.exit(0);
}
}
static int menuBanco() {
boolean opcaoValida = false;
int opcao = 0;
while (!opcaoValida) {
System.out.println("\t\tConta Corrente do Cliente 1"
+ "\n\t\tDigite o número da opção desejada."
+ "\n1) Saque;"
+ "\n2) Consulta de saldo;"
+ "\n3) Depósito;"
+ "\n4) Verificar se já está no Cheque especial;"
+ "\n 5)Sair");
opcao = scan.nextInt();
if (opcao > 0 && opcao <= 5) {
opcaoValida = true;
} else {
System.out.println("Opção inválida. Tente novamente.");
}
}
return opcao;
}
static void retornaAoMenu() {
boolean opcaoValida = false;
String[] args = new String[0];
int op = 0;
while (!opcaoValida) {
System.out.println("1) Voltar ao menu principal."
+ "\n2) Sair do programa.");
op = scan.nextInt();
if (op > 0 && op <= 2) {
opcaoValida = true;
} else {
System.out.println("\t\tMenu Saque\n\t\tOpção inválida. Tente novamente.");
}
if (op == 1) {
telaInicialSemAtribuicoes();
} else if (op == 2) {
System.exit(0);
}
}
}
static void telaInicialSemAtribuicoes() {
int opcao = menuBanco();
if (opcao == 1) {
double total = 0;
System.out.println("Digite a quantia que quer sacar.");
double quantiaPedidoSaque = scan.nextDouble();
boolean pedidoSaque = cliente1.estadoParaSaque(quantiaPedidoSaque);
if (pedidoSaque) {
total = cliente1.sacarDinheiro(quantiaPedidoSaque);
} else {
System.out.println("Você não tem saldo e/ou limite suficiente"
+ " para efetuar este saque.");
cliente1.consultarSaldo();
}
retornaAoMenu();
}
if (opcao == 2) {
cliente1.consultarSaldo();
retornaAoMenu();
}
if (opcao == 3) {
cliente1.depositarConta();
retornaAoMenu();
}
if (opcao == 4) {
cliente1.consultarChequeEspecial();
retornaAoMenu();
}
if (opcao == 5) {
System.exit(0);
}
}
}