-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPrincipal.java
73 lines (64 loc) · 2.63 KB
/
Principal.java
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
package crud;
import java.util.List;
import java.util.Scanner;
public class Principal {
public static void main(String[] args) {
DAO dao = new DAO();
dao.conectar();
Scanner scanner = new Scanner(System.in);
int opcao;
do {
System.out.println("Menu de Opções:");
System.out.println("1. Listar");
System.out.println("2. Inserir");
System.out.println("3. Excluir");
System.out.println("4. Atualizar");
System.out.println("5. Sair");
System.out.print("Escolha uma opção: ");
opcao = scanner.nextInt();
scanner.nextLine();
switch (opcao) {
case 1:
List<Animes> animes = dao.listar();
for (Animes anime : animes) {
System.out.println(anime);
}
break;
case 2:
System.out.print("Nome: ");
String nome = scanner.nextLine();
System.out.print("Episodios: ");
String episodio = scanner.nextLine();
System.out.print("Gênero: ");
String genero = scanner.nextLine();
Jogos novoSnime = new Animes(-1, nome, episodios, genero);
dao.inserir(novoAnime);
break;
case 3:
System.out.print("Digite o ID do anime para excluir: ");
int idExcluir = scanner.nextInt();
dao.excluir(idExcluir);
break;
case 4:
System.out.print("Digite o ID do anime para atualizar: ");
int idAtualizar = scanner.nextInt();
scanner.nextLine();
System.out.print("Novo Nome: ");
String novoNome = scanner.nextLine();
System.out.print("Novos Episodios: ");
String novosEpisodios = scanner.nextLine();
System.out.print("Novo Gênero: ");
String novoGenero = scanner.nextLine();
Animes animeAtualizado = new Animes(idAtualizar, novoNome, novosEpisodios, novoGenero);
dao.atualizar(animeAtualizado);
break;
case 5:
System.out.println("Saindo...");
break;
default:
System.out.println("Opção inválida. Tente novamente.");
}
} while (opcao != 5);
scanner.close();
}
}