-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain_client_sys.java
More file actions
73 lines (65 loc) · 2.69 KB
/
Copy pathMain_client_sys.java
File metadata and controls
73 lines (65 loc) · 2.69 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
import java.util.Scanner;
import java.util.ArrayList;
public class Main_client_sys {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
ArrayList<Clientes_sys> clientes = new ArrayList<>();
System.out.println("Quantos no cadastro: ");
int qtds = sc.nextInt();
for(int i=0; i< qtds; i++){
Clientes_sys c = new Clientes_sys();
c.setId(i+1);
System.out.println("Nome:");
c.setNome(sc.next());
System.out.println("Rg: ");
c.setRg(sc.next());
System.out.println("Cpf: ");
c.setCpf(sc.next());
System.out.println("Telefone: ");
c.setTelefone(sc.next());
System.out.println("E-mail: ");
c.setEmail(sc.next());
clientes.add(c);
System.out.println(c);
}
System.out.println("Digite 1 para remover um cliente, digite 2 para atualizar");
int x = sc.nextInt();
switch(x) {
case 1:
System.out.print("Digite o ID do cliente que você deseja retirar: ");
int removerIndice = sc.nextInt() - 1;
if (removerIndice >= 0 && removerIndice < clientes.size()) {
clientes.remove(removerIndice);
for (int i = 0; i < clientes.size(); i++) {
clientes.get(i).setId(i + 1);
System.out.println("Cliente removido com sucesso");
}
} else {
System.out.println("Indice invalido, tente novamente");
break;}
System.out.print(clientes);
break;
case 2:
System.out.print("Digite o ID do cliente que deseja atualizar: ");
int updateIndice = sc.nextInt() -1;
if(updateIndice>=0 && updateIndice< clientes.size()){
Clientes_sys c = clientes.get(updateIndice);
System.out.print("Nome:");
c.setNome(sc.next());
System.out.println("Rg: ");
c.setRg(sc.next());
System.out.println("Cpf: ");
c.setCpf(sc.next());
System.out.println("Telefone: ");
c.setTelefone(sc.next());
System.out.println("E-mail: ");
c.setEmail(sc.next());
break;
}else{
System.out.print("indice invalido");
break;
}
}
sc.close();
}
}