From 7b96eec7408766a8d3a9621eacec8a2cf2c010d4 Mon Sep 17 00:00:00 2001 From: Alex Araujo Date: Wed, 20 Aug 2025 20:45:42 -0300 Subject: [PATCH 1/6] finalizando conteudo interfaces e exercicios --- .gitignore | 3 +- README.md | 52 ++++++++++++++++++++++++++++ src/Main.java | 22 +++++++++++- src/exemplo/ecommerce/Produto.java | 54 ++++++++++++++++++++++++++++++ src/exemplo/imposto/ICMS.java | 42 ++++++++++++++++++++++- 5 files changed, 170 insertions(+), 3 deletions(-) create mode 100644 README.md create mode 100644 src/exemplo/ecommerce/Produto.java diff --git a/.gitignore b/.gitignore index f68d109..d4dbff9 100644 --- a/.gitignore +++ b/.gitignore @@ -26,4 +26,5 @@ bin/ .vscode/ ### Mac OS ### -.DS_Store \ No newline at end of file +.DS_Store +.idea/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..54c8d80 --- /dev/null +++ b/README.md @@ -0,0 +1,52 @@ +# 📘 Lista de Exercícios Desafios – Interfaces em Java + +Este material contém apenas os **enunciados dos exercícios** para prática. + +--- + +### **1. Criando uma Interface Simples** +Crie uma interface `Animal` com os métodos `emitirSom()` e `mover()`. +Depois, implemente-a nas classes `Cachorro` e `Gato`. +No programa principal, crie objetos das duas classes e invoque seus métodos. + +--- + +### **2. Interface com Constantes** +Crie uma interface `OperacoesMatematicas` que define constantes para `PI` e `E`, +além dos métodos `somar`, `subtrair`, `multiplicar` e `dividir`. +Implemente essa interface na classe `Calculadora`. + +--- + +### **3. Interface com `default` e `static`** +Crie uma interface `Pagamento` com o método `processarPagamento(double valor)`. +- Adicione um método `default gerarRecibo(double valor)` que imprime um recibo. +- Adicione um método `static validarValor(double valor)` que verifica se o valor é positivo. +Implemente em `CartaoCredito` e `Pix`. + +--- + +### **4. Polimorfismo com Interfaces** +Implemente um sistema de gerenciamento de arquivos com uma interface `Armazenamento` que define os métodos `salvar(String dado)` e `ler()`. +Crie implementações para: +- `BancoDeDados` (simula armazenamento em BD) +- `ArquivoTexto` (simula gravação em arquivo de texto) + +No programa principal, crie uma lista de `Armazenamento` e demonstre polimorfismo. + +--- + +### **5. Sistema de Notificações** +Desenvolva um sistema de notificações com os seguintes requisitos: +1. Crie uma interface `Notificacao` com o método `enviar(String mensagem)`. +2. Implemente pelo menos três classes que representem canais de notificação: + - `EmailNotificacao` + - `SmsNotificacao` + - `PushNotificacao` +3. Crie uma classe `GerenciadorDeNotificacoes` que receba uma lista de notificadores (injeção de dependência) e tenha um método `notificarTodos(String mensagem)`. +4. No programa principal (`main`), permita que o usuário escolha quais canais de notificação deseja utilizar. +5. O sistema deve permitir expansão futura (exemplo: adicionar `WhatsAppNotificacao` sem modificar o código existente). + +--- + +✍️ Resolva os desafios implementando as classes e interfaces solicitadas. diff --git a/src/Main.java b/src/Main.java index b0687c5..fb31f50 100644 --- a/src/Main.java +++ b/src/Main.java @@ -1,9 +1,11 @@ +import exemplo.ecommerce.Produto; import exemplo.imposto.ICMS; import exemplo.imposto.IOF; import exemplo.imposto.Imposto; import exemplo.imposto.ImpostoRecord; -import java.util.List; +import java.math.BigDecimal; +import java.util.*; public class Main { public static void main(String[] args) { @@ -25,6 +27,24 @@ public static void main(String[] args) { ImpostoRecord iva = new ImpostoRecord("2", "IVA"); //iva.taxa(); + Comparator compImposto = Comparator.comparing(Produto::getId) + .thenComparing(Produto::getValor); + //compImposto.compare(new Produto(), new Produto()); + + Integer numero = Integer.valueOf(10); + System.out.printf("O numeros sao iguais %d", numero.compareTo(Integer.valueOf(15))); + + + + + + List produtos = new ArrayList<>(); + produtos.add(new Produto(2, "TV 55", new BigDecimal(4500))); + produtos.add(new Produto(1, "PS 5", new BigDecimal(3800))); + Collections.sort(produtos); + Collections.sort(produtos, Comparator.comparing(Produto::getValor)); + produtos.sort((p1, p2) -> p1.getId().compareTo(p2.getId())); + } diff --git a/src/exemplo/ecommerce/Produto.java b/src/exemplo/ecommerce/Produto.java new file mode 100644 index 0000000..41b3610 --- /dev/null +++ b/src/exemplo/ecommerce/Produto.java @@ -0,0 +1,54 @@ +package exemplo.ecommerce; + +import java.math.BigDecimal; +import java.util.Comparator; + +public class Produto implements Comparable { + + + private Integer id; + private String descricao; + private BigDecimal valor; + + + public Integer getId() { + return id; + } + + public Produto(Integer id, String descricao, BigDecimal valor) { + this.id = id; + this.descricao = descricao; + this.valor = valor; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getDescricao() { + return descricao; + } + + public void setDescricao(String descricao) { + this.descricao = descricao; + } + + public BigDecimal getValor() { + return valor; + } + + public void setValor(BigDecimal valor) { + this.valor = valor; + } + + @Override + public int compareTo(Produto produto) { + if(this.getId() < produto.getId()) { + return -1; + } + if(this.getId() > produto.getId()) { + return 1; + } + return 0; + } +} diff --git a/src/exemplo/imposto/ICMS.java b/src/exemplo/imposto/ICMS.java index 32970e2..bdf25ef 100644 --- a/src/exemplo/imposto/ICMS.java +++ b/src/exemplo/imposto/ICMS.java @@ -1,15 +1,55 @@ package exemplo.imposto; -public class ICMS implements Imposto { +import java.util.Comparator; + +public class ICMS implements Imposto, Comparable { public Double taxa; + public Double percentual; public ICMS(Double taxa){ this.taxa = taxa; } + public Double getTaxa() { + return taxa; + } + + public void setTaxa(Double taxa) { + this.taxa = taxa; + } + + public Double getPercentual() { + return percentual; + } + + public void setPercentual(Double percentual) { + this.percentual = percentual; + } + @Override public void calcular(){ System.out.println("CALCULANDO ICMS"); } + @Override + public int compareTo(ICMS o) { + + /* if(this.taxa < o.taxa + && this.percentual < o.percentual) { + + return -1; + } + + if(this.taxa > o.taxa + && this.percentual > o.percentual) { + + return 1; + + return 0;*/ + Comparator comp = Comparator.comparing(ICMS::getTaxa) + .thenComparing(ICMS::getPercentual); + + return comp.compare(this, o); + + } } From b0f6795517d4b8568a2cb619031bd0c6f9587ab3 Mon Sep 17 00:00:00 2001 From: Matheus Gomes de Moura Date: Sun, 24 Aug 2025 23:30:14 -0300 Subject: [PATCH 2/6] add: desafio 1 --- src/desafio/Desafio.java | 34 +++++++++++++++++++ src/exercicios/EmailNotificacao.java | 4 +++ .../GerenciadorDeNotificadores.java | 4 +++ src/exercicios/Main.java | 4 +++ src/exercicios/Notificacao.java | 4 +++ src/exercicios/SmsNotificacao.java | 4 +++ src/exercicios/pushNotificacao.java | 4 +++ 7 files changed, 58 insertions(+) create mode 100644 src/desafio/Desafio.java create mode 100644 src/exercicios/EmailNotificacao.java create mode 100644 src/exercicios/GerenciadorDeNotificadores.java create mode 100644 src/exercicios/Main.java create mode 100644 src/exercicios/Notificacao.java create mode 100644 src/exercicios/SmsNotificacao.java create mode 100644 src/exercicios/pushNotificacao.java diff --git a/src/desafio/Desafio.java b/src/desafio/Desafio.java new file mode 100644 index 0000000..b5912ec --- /dev/null +++ b/src/desafio/Desafio.java @@ -0,0 +1,34 @@ +package desafio; + +import java.util.*; + +public class Desafio { + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + + int n = sc.nextInt(); + sc.nextLine(); + + String[] pedras = new String[n]; + for(int i=0;i comuns = new HashSet<>(); + for(char c: pedras[0].toCharArray()){ + comuns.add(c); + } + + for(int i=1;i atual = new HashSet<>(); + for(char c : pedras[i].toCharArray()) { + atual.add(c); + } + comuns.retainAll(atual); + } + + System.out.println(comuns.size()); + + } +} diff --git a/src/exercicios/EmailNotificacao.java b/src/exercicios/EmailNotificacao.java new file mode 100644 index 0000000..390df3d --- /dev/null +++ b/src/exercicios/EmailNotificacao.java @@ -0,0 +1,4 @@ +package exercicios; + +public class EmailNotificacao { +} diff --git a/src/exercicios/GerenciadorDeNotificadores.java b/src/exercicios/GerenciadorDeNotificadores.java new file mode 100644 index 0000000..4d7ac66 --- /dev/null +++ b/src/exercicios/GerenciadorDeNotificadores.java @@ -0,0 +1,4 @@ +package exercicios; + +public class GerenciadorDeNotificadores { +} diff --git a/src/exercicios/Main.java b/src/exercicios/Main.java new file mode 100644 index 0000000..05ecaeb --- /dev/null +++ b/src/exercicios/Main.java @@ -0,0 +1,4 @@ +package exercicios; + +public class Main { +} diff --git a/src/exercicios/Notificacao.java b/src/exercicios/Notificacao.java new file mode 100644 index 0000000..128f0ca --- /dev/null +++ b/src/exercicios/Notificacao.java @@ -0,0 +1,4 @@ +package exercicios; + +public interface Notificacao { +} diff --git a/src/exercicios/SmsNotificacao.java b/src/exercicios/SmsNotificacao.java new file mode 100644 index 0000000..11360c7 --- /dev/null +++ b/src/exercicios/SmsNotificacao.java @@ -0,0 +1,4 @@ +package exercicios; + +public class SmsNotificacao { +} diff --git a/src/exercicios/pushNotificacao.java b/src/exercicios/pushNotificacao.java new file mode 100644 index 0000000..3eda527 --- /dev/null +++ b/src/exercicios/pushNotificacao.java @@ -0,0 +1,4 @@ +package exercicios; + +public class pushNotificacao { +} From 951f11853f0c5adf99991c8758846c3c38058757 Mon Sep 17 00:00:00 2001 From: Matheus Gomes de Moura Date: Tue, 26 Aug 2025 00:01:07 -0300 Subject: [PATCH 3/6] exercicio 5 --- src/exercicios/EmailNotificacao.java | 4 ++++ .../GerenciadorDeNotificadores.java | 11 ++++++++++ src/exercicios/Main.java | 22 +++++++++++++++++++ src/exercicios/Notificacao.java | 1 + src/exercicios/SmsNotificacao.java | 6 ++++- src/exercicios/pushNotificacao.java | 6 +++++ 6 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/exercicios/EmailNotificacao.java b/src/exercicios/EmailNotificacao.java index 390df3d..1751ecb 100644 --- a/src/exercicios/EmailNotificacao.java +++ b/src/exercicios/EmailNotificacao.java @@ -1,4 +1,8 @@ package exercicios; public class EmailNotificacao { + @Override + public void enviar(String mensagem) { + System.out.println("Enviando Email" + mensagem); + } } diff --git a/src/exercicios/GerenciadorDeNotificadores.java b/src/exercicios/GerenciadorDeNotificadores.java index 4d7ac66..46b53ee 100644 --- a/src/exercicios/GerenciadorDeNotificadores.java +++ b/src/exercicios/GerenciadorDeNotificadores.java @@ -1,4 +1,15 @@ package exercicios; public class GerenciadorDeNotificadores { + private List notificadores; + + public GerenciadorDeNotificacoes(List notificadores) { + this.notificadores = notificadores; + } + + public void notificarTodos(String mensagem) { + for (Notificacao notificacao : notificadores) { + notificacao.enviar(mensagem); + } + } } diff --git a/src/exercicios/Main.java b/src/exercicios/Main.java index 05ecaeb..a94d81a 100644 --- a/src/exercicios/Main.java +++ b/src/exercicios/Main.java @@ -1,4 +1,26 @@ package exercicios; public class Main { + Scanner scanner = new Scanner(System.in); + List canaisSelecionados = new ArrayList(); + + System.out.println("Escolha os canais de notificação (separe por vírgula): \n" + + "1 - Email \n" + + "2- SMS \n" + + "3- Push"); + + String[] opcoes = scanner.nextLine().split(","); + for (String opcao : opcoes) { + switch (opcao.trim()) { + case "1" -> canaisSelecionados.add(new EmailNotificacao()); + case "2" -> canaisSelecionados.add(new SmsNotificacao()); + case "3" -> canaisSelecionados.add(new PushNotificacao()); + default -> System.out.println("Opção inválida: " + opcao); + } + } + + System.out.println("Digite a mensagem que deseja enviar:"); + String mensagem = scanner.nextLine(); + + gerenciador.notificarTodos(mensagem); } diff --git a/src/exercicios/Notificacao.java b/src/exercicios/Notificacao.java index 128f0ca..64b7eef 100644 --- a/src/exercicios/Notificacao.java +++ b/src/exercicios/Notificacao.java @@ -1,4 +1,5 @@ package exercicios; public interface Notificacao { + void enviar(String mensagem); } diff --git a/src/exercicios/SmsNotificacao.java b/src/exercicios/SmsNotificacao.java index 11360c7..73c0058 100644 --- a/src/exercicios/SmsNotificacao.java +++ b/src/exercicios/SmsNotificacao.java @@ -1,4 +1,8 @@ package exercicios; public class SmsNotificacao { -} + @Override + public void enviar(String mensagem) { + System.out.println("Enviando SMS: " + mensagem); + } +} \ No newline at end of file diff --git a/src/exercicios/pushNotificacao.java b/src/exercicios/pushNotificacao.java index 3eda527..d9f7e7c 100644 --- a/src/exercicios/pushNotificacao.java +++ b/src/exercicios/pushNotificacao.java @@ -1,4 +1,10 @@ package exercicios; public class pushNotificacao { + @Override + public void enviar(String mensagem) { + System.out.println("Enviando Push Notification: " + mensagem); + } } + + From 8bbe1f7c0574b30aaec1fedc503ad98c19f2f263 Mon Sep 17 00:00:00 2001 From: Matheus Gomes de Moura Date: Wed, 27 Aug 2025 23:54:50 -0300 Subject: [PATCH 4/6] desafio 2 --- src/desafio/Desafio.java | 34 ----------------- .../EmailNotificacao.java | 0 .../GerenciadorDeNotificadores.java | 0 src/{exercicios => desafioV}/Main.java | 0 src/{exercicios => desafioV}/Notificacao.java | 0 .../SmsNotificacao.java | 0 .../pushNotificacao.java | 0 src/desafioVIII/Cliente.class | Bin 0 -> 966 bytes src/desafioVIII/Cliente.java | 21 +++++++++++ src/desafioVIII/Identificavel.class | Bin 0 -> 141 bytes src/desafioVIII/Identificavel.java | 5 +++ src/desafioVIII/Main.class | Bin 0 -> 1928 bytes src/desafioVIII/Main.java | 35 ++++++++++++++++++ src/desafioVIII/Produto.class | Bin 0 -> 966 bytes src/desafioVIII/Produto.java | 21 +++++++++++ src/desafioVIII/Repositorio.class | Bin 0 -> 376 bytes src/desafioVIII/Repositorio.java | 9 +++++ src/desafioVIII/RepositorioCliente.class | Bin 0 -> 314 bytes src/desafioVIII/RepositorioCliente.java | 3 ++ src/desafioVIII/RepositorioMemoria.class | Bin 0 -> 1352 bytes src/desafioVIII/RepositorioMemoria.java | 28 ++++++++++++++ src/desafioVIII/RepositorioProduto.class | Bin 0 -> 314 bytes src/desafioVIII/RepositorioProduto.java | 4 ++ 23 files changed, 126 insertions(+), 34 deletions(-) delete mode 100644 src/desafio/Desafio.java rename src/{exercicios => desafioV}/EmailNotificacao.java (100%) rename src/{exercicios => desafioV}/GerenciadorDeNotificadores.java (100%) rename src/{exercicios => desafioV}/Main.java (100%) rename src/{exercicios => desafioV}/Notificacao.java (100%) rename src/{exercicios => desafioV}/SmsNotificacao.java (100%) rename src/{exercicios => desafioV}/pushNotificacao.java (100%) create mode 100644 src/desafioVIII/Cliente.class create mode 100644 src/desafioVIII/Cliente.java create mode 100644 src/desafioVIII/Identificavel.class create mode 100644 src/desafioVIII/Identificavel.java create mode 100644 src/desafioVIII/Main.class create mode 100644 src/desafioVIII/Main.java create mode 100644 src/desafioVIII/Produto.class create mode 100644 src/desafioVIII/Produto.java create mode 100644 src/desafioVIII/Repositorio.class create mode 100644 src/desafioVIII/Repositorio.java create mode 100644 src/desafioVIII/RepositorioCliente.class create mode 100644 src/desafioVIII/RepositorioCliente.java create mode 100644 src/desafioVIII/RepositorioMemoria.class create mode 100644 src/desafioVIII/RepositorioMemoria.java create mode 100644 src/desafioVIII/RepositorioProduto.class create mode 100644 src/desafioVIII/RepositorioProduto.java diff --git a/src/desafio/Desafio.java b/src/desafio/Desafio.java deleted file mode 100644 index b5912ec..0000000 --- a/src/desafio/Desafio.java +++ /dev/null @@ -1,34 +0,0 @@ -package desafio; - -import java.util.*; - -public class Desafio { - public static void main(String[] args) { - Scanner sc = new Scanner(System.in); - - int n = sc.nextInt(); - sc.nextLine(); - - String[] pedras = new String[n]; - for(int i=0;i comuns = new HashSet<>(); - for(char c: pedras[0].toCharArray()){ - comuns.add(c); - } - - for(int i=1;i atual = new HashSet<>(); - for(char c : pedras[i].toCharArray()) { - atual.add(c); - } - comuns.retainAll(atual); - } - - System.out.println(comuns.size()); - - } -} diff --git a/src/exercicios/EmailNotificacao.java b/src/desafioV/EmailNotificacao.java similarity index 100% rename from src/exercicios/EmailNotificacao.java rename to src/desafioV/EmailNotificacao.java diff --git a/src/exercicios/GerenciadorDeNotificadores.java b/src/desafioV/GerenciadorDeNotificadores.java similarity index 100% rename from src/exercicios/GerenciadorDeNotificadores.java rename to src/desafioV/GerenciadorDeNotificadores.java diff --git a/src/exercicios/Main.java b/src/desafioV/Main.java similarity index 100% rename from src/exercicios/Main.java rename to src/desafioV/Main.java diff --git a/src/exercicios/Notificacao.java b/src/desafioV/Notificacao.java similarity index 100% rename from src/exercicios/Notificacao.java rename to src/desafioV/Notificacao.java diff --git a/src/exercicios/SmsNotificacao.java b/src/desafioV/SmsNotificacao.java similarity index 100% rename from src/exercicios/SmsNotificacao.java rename to src/desafioV/SmsNotificacao.java diff --git a/src/exercicios/pushNotificacao.java b/src/desafioV/pushNotificacao.java similarity index 100% rename from src/exercicios/pushNotificacao.java rename to src/desafioV/pushNotificacao.java diff --git a/src/desafioVIII/Cliente.class b/src/desafioVIII/Cliente.class new file mode 100644 index 0000000000000000000000000000000000000000..47b7e26671d7d8fc0e7256b3cd0c15f5f7a13c3a GIT binary patch literal 966 zcmaJ=U2hUW6g|V&QlwC!w$^HGm6i{&Jotz;QIf_@P#+pI6@jJVzsg7~&2RStOBSSUcx4-tf5^ zG~V>iMc*)_o=PRnGlqDj+Fd~!D-JSQ+(4G0=!t-zO5Jr`x6$&YP)0Dsq{qNqi_K+` z#~MRI=@Fe2+Sm0vW+K&~Ss)&TEQ(lX*c|bpXld2w=B+em^cEPdOu$gCxQnUP#gKyy zhOK#4u1BQgsqFKa@EJCi7U~kimiCBYzAcq_JstJLU?zP0N|-b41!+8>wjqU$AN>gRj9&Hy4FvsnI4Kp$R-r+nD>pITrhmB%t;dg!y8|6<@q8gwY45j$IUrd z^gZSxexLh(5HeC-=pZTk{Vt$vBsFBGCl zB3nR$Ed3&O^y$eVLnn8z9Tm7oo)IEh`wHjNpS0BPV2Nv#KFFB9sSpWb4 literal 0 HcmV?d00001 diff --git a/src/desafioVIII/Cliente.java b/src/desafioVIII/Cliente.java new file mode 100644 index 0000000..3b8d1cc --- /dev/null +++ b/src/desafioVIII/Cliente.java @@ -0,0 +1,21 @@ +package desafioVIII; + +public class Cliente implements Identificavel { + private int id; + private String nome; + + public Cliente(int id, String nome) { + this.id = id; + this.nome = nome; + } + + @Override + public int getId() { + return id; + } + + @Override + public String toString() { + return "Cliente{id=" + id + ", nome='" + nome + "'}"; + } +} \ No newline at end of file diff --git a/src/desafioVIII/Identificavel.class b/src/desafioVIII/Identificavel.class new file mode 100644 index 0000000000000000000000000000000000000000..4fc6855f5623c0a88802c505810aba54c90b67d4 GIT binary patch literal 141 zcmX^0Z`VEs1_nn4PId++Mh3~0)Z)an%=|DJb_Nzk27#=^ zvPAuy#JqHU|D>$cLQ z7J1`G@Bk7Lk9~#*hc*)8g%>0w_z(OFgbHWYYr0O_CeqHCbDQsc=gj!G$B%vnumE32 z4|+Ak48+mLFtW>=JZp1jJG)Ze6&0VM?}p`A{!ND7bY@*cf?>KUJicYgb<;GncST)# zmM>jPuDY_?@TCq-r5t#+W8Sue;|m?SavWk9jb;qfBrw8|SeCvhOSz|G5J?4clwl%m z7M|cN`L5+`=Q8W++;IaFI7y&AZa2A05YmNcZnH`UTU%CzH-$|x2~0A?i?ZPf4X2L) z31KF1hCwTGe@8St9aBgu;NuCLBTg0^-jA0sqv5=P3wXJU!qUFyiyC>!1`#>l25rgg zDk1g>x8Sv$LY*;i5wi>f<%U<`?y7Xns)BB2o&#RTC0y2!HSh|qbRQcqLYSM}ZitmF zh70KkVeQ7|G7(kCVUlLznt@mG8pFvN-xGQ1RJec7@^?t`eD3((kz^hAk0;Y{9dBrO z)4)7(#B9*9?&1kzT~T2>#7-1qCoA<-MS;xD~Nzso;K<{IaT^4!tF%@A)pT7lpqgt6l=+F&efgRgtxnc{_Dw zKE)E)CPRq3W4KC&;XYV8cCn|yRuf3KW+tFEV90Wsa!+L2W6>VUMP8vc?K6B69h}gy z4P%KrRaZt3H*aP|`T z!}()1Jq@Y`^>RJmmEO2^T{wsP^oXm!9=a&>jMMjH+MS`5(Hg&a0QLh344=?fnbo%+ zpW-u;$(5ND7ANhWhtM_-&|f%&PODLzJ;dNfEIE9D6D^DdyLj?cdpCE8DYCtAfaw;_ z2D^AN)!zMx7iVKFq<_NPBU}Yqc%4*p@fL0bs<%3-knNKVjyKSp3+nto8`NSY`8 z62`EJaX2`ICMNMUJ@Vh-G`=SeACTv-IE&wr!XL!-=agj%vB&sIgQh{(aOZDK|AP~4 g0lnbCnPpUH9ir2Bh~#SU-J%mfSCv8H3wW6P5Bi+($p8QV literal 0 HcmV?d00001 diff --git a/src/desafioVIII/Main.java b/src/desafioVIII/Main.java new file mode 100644 index 0000000..741b170 --- /dev/null +++ b/src/desafioVIII/Main.java @@ -0,0 +1,35 @@ +package desafioVIII; + +import java.util.*; + + +public class Main { + public static void main(String[] args) { + RepositorioProduto repoProdutos = new RepositorioProduto(); + RepositorioCliente repoClientes = new RepositorioCliente(); + + // Salvando produtos + repoProdutos.salvar(new Produto(1, "Notebook")); + repoProdutos.salvar(new Produto(2, "Mouse")); + + // Salvando clientes + repoClientes.salvar(new Cliente(1, "Matheus")); + repoClientes.salvar(new Cliente(2, "Ana")); + + // Testando busca + System.out.println("Produto com ID 1: " + repoProdutos.buscarPorId(1)); + System.out.println("Cliente com ID 2: " + repoClientes.buscarPorId(2)); + + // Listando todos + System.out.println("\nLista de Produtos:"); + for (Produto p : repoProdutos.listarTodos()) { + System.out.println(p); + } + + System.out.println("\nLista de Clientes:"); + for (Cliente c : repoClientes.listarTodos()) { + System.out.println(c); + } + } +} + diff --git a/src/desafioVIII/Produto.class b/src/desafioVIII/Produto.class new file mode 100644 index 0000000000000000000000000000000000000000..71ec15792153963acf003ff0e5827f88c4d81a4d GIT binary patch literal 966 zcmaJ=T~8BH5IxhcEw!}RB8Vu07W!eO4?b2*vwf%WKqO2VRaz-vZaHbFmIJP<-5p;z(j;{#hp#9&W0SU z5Z0zyxtgzvYNkxf>_4FVaqd=W)5a`1?-Ju}lhstz6# zHvSLgWgX9jE#AEt2)EeA?5^^b#q27wk8?bURkpYJ=?TZVNxqE-?Uu|A&OV^ZoLlHX&YleNO$re3nTa2V!7F=Di9(s z%|SZCeYQBCKIUt}aHY3<85*Zp&dTx_CY#1r(!E$G>b5HKZn@P(&ILkZv=7piwzi%y z&i?EsXj3eB#LA=-&bT_~Nj57Vy06c>5n;5ljjPnNHvHN2-}cjXwTM9I^R0kBAL9ZM cbIjDkCG!xY6DQ19xIXa>JHO^F(qrT92hcNG=>Px# literal 0 HcmV?d00001 diff --git a/src/desafioVIII/Repositorio.java b/src/desafioVIII/Repositorio.java new file mode 100644 index 0000000..5e7ace4 --- /dev/null +++ b/src/desafioVIII/Repositorio.java @@ -0,0 +1,9 @@ +package desafioVIII; +import java.util.List; + + +public interface Repositorio { + void salvar(T obj); + T buscarPorId(int id); + List listarTodos(); +} diff --git a/src/desafioVIII/RepositorioCliente.class b/src/desafioVIII/RepositorioCliente.class new file mode 100644 index 0000000000000000000000000000000000000000..7e7ed6c0a0cec0649a0b818f450be58244ba9cc5 GIT binary patch literal 314 zcmaJ+%MQU%5It8>tw)zuBz9P^v>+0ZNSa`Q*k5|d2)$CR|FV);_y8Xzri}#)W|BEG zbLRPY-tGVfaBQStm`E3pK~|vZsgvB0Ub?Q^o~ffgQK$pb6Lnya0@)t<6!ry-dShuK z_q%1dC*_AqAU)I`gEJ;yO{2p~1q->_bH { } \ No newline at end of file diff --git a/src/desafioVIII/RepositorioMemoria.class b/src/desafioVIII/RepositorioMemoria.class new file mode 100644 index 0000000000000000000000000000000000000000..aaff5d722066377f4cf1ec8ad9dfbea916b18547 GIT binary patch literal 1352 zcmaJ=T~8BH5IwhFOWQ>%P!I}L6lJ#*ir-3WwPH**X^}{S(YM>~0*j?fwp*e<#W&x4 z#Y7?1#Q5yL@NXES&fRWh0p($LcJItNGjrz7w_l&W04U*63;_fsgk*#fVMuK8U7l<3 z=0@&GZOf=T43UD_G@T+tP*K+;^f3&%L2buu9Uzg366N7|c6miHB`emHK07F_g zT72EK)-+AaJvDZ$mg!iwX;qAEGMpjYASBsD`H)eN<>NSuK?y@LhLL1AbJR_xa9w9e zDqWnf+`RfiU`J(~!x%%K=@>Srqzog9>dT^e=aeah2?>)j(m2mBc$ldd!XRz(*0S-6 zv>*wHKZPk77jcOp)O3%Bd))p?BwS_~^Gl%VM$<9Z%{t#T8gWcxMuq~Fbl5N)jT$0) zEk+v7%E)4lAzo{@>fBzjY~f8Snp*xZUtR!nG8S-^X4c}3T~1x6l~WL6oYxsf{hYor zF+^9*jV5>6wn1Y1)Dtr*RIB-7o+MbZbaD@r&8D&3-mV#TmDd_{5>Y5ZU1R89b$I<{ zh41`zXezm=J$L+e)zYmNN#7IEy;$xwpxRCx_VOl$8t%0GqSIZf7|y1puW*}h8#HBN z{^vcR!d42^#l=(fDW2p%67AEfS5<7)YTI?=u_+W7^#yo$eqK}@nxat!z;KP8kk}Qn zH)tONxQPgT(<;*Y7M)}fq%RC$=VO|l_E&kJ-1BMg;n2jdKHFhL&|7`|e9d9H&i z45_yW&+WbY{hjR*BH&gvLOoE`n51Q#!5~yx*vgkq5WL+ULseNRQV21+er7Z-O7@ literal 0 HcmV?d00001 diff --git a/src/desafioVIII/RepositorioMemoria.java b/src/desafioVIII/RepositorioMemoria.java new file mode 100644 index 0000000..ad4860d --- /dev/null +++ b/src/desafioVIII/RepositorioMemoria.java @@ -0,0 +1,28 @@ +package desafioVIII; +import java.util.ArrayList; +import java.util.List; + +// Classe abstrata que implementa a interface +public abstract class RepositorioMemoria implements Repositorio { + protected List lista = new ArrayList<>(); + + @Override + public void salvar(T obj) { + lista.add(obj); + } + + @Override + public T buscarPorId(int id) { + for (T obj : lista) { + if (obj.getId() == id) { + return obj; + } + } + return null; + } + + @Override + public List listarTodos() { + return lista; + } +} diff --git a/src/desafioVIII/RepositorioProduto.class b/src/desafioVIII/RepositorioProduto.class new file mode 100644 index 0000000000000000000000000000000000000000..628116e3b511fd222e04ad1db6e35da6105f92e5 GIT binary patch literal 314 zcmaJ+%?`mp5dKzC>hI`8;)Vl92O<%Pq)CaW^uBb-3SC*P_i~arcmNM2ri}v!W|H}4 z=9}Ng^L7U?Ld8M~hKY0$8DtsizBuuXRGw|y-Gw-+lMI!XYAOx{oFO}qfeeQXMziIa z$o+1aYvo6wVn~mbFBmG048$xttb|_j)t)kWS8f9yMwg@QLqXCmXjfIiYuVnKS)sh&7gto}WG+ { } + From 47b369ab112b1db7b1abe85908959d7753753c82 Mon Sep 17 00:00:00 2001 From: Matheus Gomes de Moura Date: Wed, 27 Aug 2025 23:59:06 -0300 Subject: [PATCH 5/6] Removendo .class distribuidos incorretamente ao longo da pasta --- src/desafioVIII/Cliente.class | Bin 966 -> 0 bytes src/desafioVIII/Identificavel.class | Bin 141 -> 0 bytes src/desafioVIII/Main.class | Bin 1928 -> 0 bytes src/desafioVIII/Produto.class | Bin 966 -> 0 bytes src/desafioVIII/Repositorio.class | Bin 376 -> 0 bytes src/desafioVIII/RepositorioCliente.class | Bin 314 -> 0 bytes src/desafioVIII/RepositorioMemoria.class | Bin 1352 -> 0 bytes src/desafioVIII/RepositorioProduto.class | Bin 314 -> 0 bytes 8 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 src/desafioVIII/Cliente.class delete mode 100644 src/desafioVIII/Identificavel.class delete mode 100644 src/desafioVIII/Main.class delete mode 100644 src/desafioVIII/Produto.class delete mode 100644 src/desafioVIII/Repositorio.class delete mode 100644 src/desafioVIII/RepositorioCliente.class delete mode 100644 src/desafioVIII/RepositorioMemoria.class delete mode 100644 src/desafioVIII/RepositorioProduto.class diff --git a/src/desafioVIII/Cliente.class b/src/desafioVIII/Cliente.class deleted file mode 100644 index 47b7e26671d7d8fc0e7256b3cd0c15f5f7a13c3a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 966 zcmaJ=U2hUW6g|V&QlwC!w$^HGm6i{&Jotz;QIf_@P#+pI6@jJVzsg7~&2RStOBSSUcx4-tf5^ zG~V>iMc*)_o=PRnGlqDj+Fd~!D-JSQ+(4G0=!t-zO5Jr`x6$&YP)0Dsq{qNqi_K+` z#~MRI=@Fe2+Sm0vW+K&~Ss)&TEQ(lX*c|bpXld2w=B+em^cEPdOu$gCxQnUP#gKyy zhOK#4u1BQgsqFKa@EJCi7U~kimiCBYzAcq_JstJLU?zP0N|-b41!+8>wjqU$AN>gRj9&Hy4FvsnI4Kp$R-r+nD>pITrhmB%t;dg!y8|6<@q8gwY45j$IUrd z^gZSxexLh(5HeC-=pZTk{Vt$vBsFBGCl zB3nR$Ed3&O^y$eVLnn8z9Tm7oo)IEh`wHjNpS0BPV2Nv#KFFB9sSpWb4 diff --git a/src/desafioVIII/Identificavel.class b/src/desafioVIII/Identificavel.class deleted file mode 100644 index 4fc6855f5623c0a88802c505810aba54c90b67d4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 141 zcmX^0Z`VEs1_nn4PId++Mh3~0)Z)an%=|DJb_Nzk27#=^ zvPAuy#JqHU|D>$cLQ z7J1`G@Bk7Lk9~#*hc*)8g%>0w_z(OFgbHWYYr0O_CeqHCbDQsc=gj!G$B%vnumE32 z4|+Ak48+mLFtW>=JZp1jJG)Ze6&0VM?}p`A{!ND7bY@*cf?>KUJicYgb<;GncST)# zmM>jPuDY_?@TCq-r5t#+W8Sue;|m?SavWk9jb;qfBrw8|SeCvhOSz|G5J?4clwl%m z7M|cN`L5+`=Q8W++;IaFI7y&AZa2A05YmNcZnH`UTU%CzH-$|x2~0A?i?ZPf4X2L) z31KF1hCwTGe@8St9aBgu;NuCLBTg0^-jA0sqv5=P3wXJU!qUFyiyC>!1`#>l25rgg zDk1g>x8Sv$LY*;i5wi>f<%U<`?y7Xns)BB2o&#RTC0y2!HSh|qbRQcqLYSM}ZitmF zh70KkVeQ7|G7(kCVUlLznt@mG8pFvN-xGQ1RJec7@^?t`eD3((kz^hAk0;Y{9dBrO z)4)7(#B9*9?&1kzT~T2>#7-1qCoA<-MS;xD~Nzso;K<{IaT^4!tF%@A)pT7lpqgt6l=+F&efgRgtxnc{_Dw zKE)E)CPRq3W4KC&;XYV8cCn|yRuf3KW+tFEV90Wsa!+L2W6>VUMP8vc?K6B69h}gy z4P%KrRaZt3H*aP|`T z!}()1Jq@Y`^>RJmmEO2^T{wsP^oXm!9=a&>jMMjH+MS`5(Hg&a0QLh344=?fnbo%+ zpW-u;$(5ND7ANhWhtM_-&|f%&PODLzJ;dNfEIE9D6D^DdyLj?cdpCE8DYCtAfaw;_ z2D^AN)!zMx7iVKFq<_NPBU}Yqc%4*p@fL0bs<%3-knNKVjyKSp3+nto8`NSY`8 z62`EJaX2`ICMNMUJ@Vh-G`=SeACTv-IE&wr!XL!-=agj%vB&sIgQh{(aOZDK|AP~4 g0lnbCnPpUH9ir2Bh~#SU-J%mfSCv8H3wW6P5Bi+($p8QV diff --git a/src/desafioVIII/Produto.class b/src/desafioVIII/Produto.class deleted file mode 100644 index 71ec15792153963acf003ff0e5827f88c4d81a4d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 966 zcmaJ=T~8BH5IxhcEw!}RB8Vu07W!eO4?b2*vwf%WKqO2VRaz-vZaHbFmIJP<-5p;z(j;{#hp#9&W0SU z5Z0zyxtgzvYNkxf>_4FVaqd=W)5a`1?-Ju}lhstz6# zHvSLgWgX9jE#AEt2)EeA?5^^b#q27wk8?bURkpYJ=?TZVNxqE-?Uu|A&OV^ZoLlHX&YleNO$re3nTa2V!7F=Di9(s z%|SZCeYQBCKIUt}aHY3<85*Zp&dTx_CY#1r(!E$G>b5HKZn@P(&ILkZv=7piwzi%y z&i?EsXj3eB#LA=-&bT_~Nj57Vy06c>5n;5ljjPnNHvHN2-}cjXwTM9I^R0kBAL9ZM cbIjDkCG!xY6DQ19xIXa>JHO^F(qrT92hcNG=>Px# diff --git a/src/desafioVIII/RepositorioCliente.class b/src/desafioVIII/RepositorioCliente.class deleted file mode 100644 index 7e7ed6c0a0cec0649a0b818f450be58244ba9cc5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 314 zcmaJ+%MQU%5It8>tw)zuBz9P^v>+0ZNSa`Q*k5|d2)$CR|FV);_y8Xzri}#)W|BEG zbLRPY-tGVfaBQStm`E3pK~|vZsgvB0Ub?Q^o~ffgQK$pb6Lnya0@)t<6!ry-dShuK z_q%1dC*_AqAU)I`gEJ;yO{2p~1q->_bH%P!I}L6lJ#*ir-3WwPH**X^}{S(YM>~0*j?fwp*e<#W&x4 z#Y7?1#Q5yL@NXES&fRWh0p($LcJItNGjrz7w_l&W04U*63;_fsgk*#fVMuK8U7l<3 z=0@&GZOf=T43UD_G@T+tP*K+;^f3&%L2buu9Uzg366N7|c6miHB`emHK07F_g zT72EK)-+AaJvDZ$mg!iwX;qAEGMpjYASBsD`H)eN<>NSuK?y@LhLL1AbJR_xa9w9e zDqWnf+`RfiU`J(~!x%%K=@>Srqzog9>dT^e=aeah2?>)j(m2mBc$ldd!XRz(*0S-6 zv>*wHKZPk77jcOp)O3%Bd))p?BwS_~^Gl%VM$<9Z%{t#T8gWcxMuq~Fbl5N)jT$0) zEk+v7%E)4lAzo{@>fBzjY~f8Snp*xZUtR!nG8S-^X4c}3T~1x6l~WL6oYxsf{hYor zF+^9*jV5>6wn1Y1)Dtr*RIB-7o+MbZbaD@r&8D&3-mV#TmDd_{5>Y5ZU1R89b$I<{ zh41`zXezm=J$L+e)zYmNN#7IEy;$xwpxRCx_VOl$8t%0GqSIZf7|y1puW*}h8#HBN z{^vcR!d42^#l=(fDW2p%67AEfS5<7)YTI?=u_+W7^#yo$eqK}@nxat!z;KP8kk}Qn zH)tONxQPgT(<;*Y7M)}fq%RC$=VO|l_E&kJ-1BMg;n2jdKHFhL&|7`|e9d9H&i z45_yW&+WbY{hjR*BH&gvLOoE`n51Q#!5~yx*vgkq5WL+ULseNRQV21+er7Z-O7@ diff --git a/src/desafioVIII/RepositorioProduto.class b/src/desafioVIII/RepositorioProduto.class deleted file mode 100644 index 628116e3b511fd222e04ad1db6e35da6105f92e5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 314 zcmaJ+%?`mp5dKzC>hI`8;)Vl92O<%Pq)CaW^uBb-3SC*P_i~arcmNM2ri}v!W|H}4 z=9}Ng^L7U?Ld8M~hKY0$8DtsizBuuXRGw|y-Gw-+lMI!XYAOx{oFO}qfeeQXMziIa z$o+1aYvo6wVn~mbFBmG048$xttb|_j)t)kWS8f9yMwg@QLqXCmXjfIiYuVnKS)sh&7gto}WG+ Date: Mon, 1 Sep 2025 23:23:48 -0300 Subject: [PATCH 6/6] chore: ajustar nome --- src/desafioV/EmailNotificacao.java | 2 +- src/desafioV/GerenciadorDeNotificadores.java | 2 +- src/desafioV/Main.java | 2 +- src/desafioV/Notificacao.java | 2 +- src/desafioV/SmsNotificacao.java | 2 +- src/desafioV/pushNotificacao.java | 2 +- src/desafioVIII/Teste.java | 4 ++++ src/desafioVIII/readme | 0 src/desafioVIII/readme.txt | 0 9 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 src/desafioVIII/Teste.java create mode 100644 src/desafioVIII/readme create mode 100644 src/desafioVIII/readme.txt diff --git a/src/desafioV/EmailNotificacao.java b/src/desafioV/EmailNotificacao.java index 1751ecb..4cebfb0 100644 --- a/src/desafioV/EmailNotificacao.java +++ b/src/desafioV/EmailNotificacao.java @@ -1,4 +1,4 @@ -package exercicios; +package desafioV; public class EmailNotificacao { @Override diff --git a/src/desafioV/GerenciadorDeNotificadores.java b/src/desafioV/GerenciadorDeNotificadores.java index 46b53ee..be3a08f 100644 --- a/src/desafioV/GerenciadorDeNotificadores.java +++ b/src/desafioV/GerenciadorDeNotificadores.java @@ -1,4 +1,4 @@ -package exercicios; +package desafioV; public class GerenciadorDeNotificadores { private List notificadores; diff --git a/src/desafioV/Main.java b/src/desafioV/Main.java index a94d81a..4b533fc 100644 --- a/src/desafioV/Main.java +++ b/src/desafioV/Main.java @@ -1,4 +1,4 @@ -package exercicios; +package desafioV; public class Main { Scanner scanner = new Scanner(System.in); diff --git a/src/desafioV/Notificacao.java b/src/desafioV/Notificacao.java index 64b7eef..e9c89ae 100644 --- a/src/desafioV/Notificacao.java +++ b/src/desafioV/Notificacao.java @@ -1,4 +1,4 @@ -package exercicios; +package desafioV; public interface Notificacao { void enviar(String mensagem); diff --git a/src/desafioV/SmsNotificacao.java b/src/desafioV/SmsNotificacao.java index 73c0058..47089c0 100644 --- a/src/desafioV/SmsNotificacao.java +++ b/src/desafioV/SmsNotificacao.java @@ -1,4 +1,4 @@ -package exercicios; +package desafioV; public class SmsNotificacao { @Override diff --git a/src/desafioV/pushNotificacao.java b/src/desafioV/pushNotificacao.java index d9f7e7c..09198ff 100644 --- a/src/desafioV/pushNotificacao.java +++ b/src/desafioV/pushNotificacao.java @@ -1,4 +1,4 @@ -package exercicios; +package desafioV; public class pushNotificacao { @Override diff --git a/src/desafioVIII/Teste.java b/src/desafioVIII/Teste.java new file mode 100644 index 0000000..b3af52a --- /dev/null +++ b/src/desafioVIII/Teste.java @@ -0,0 +1,4 @@ +package desafioVIII; + +public enum Teste { +} diff --git a/src/desafioVIII/readme b/src/desafioVIII/readme new file mode 100644 index 0000000..e69de29 diff --git a/src/desafioVIII/readme.txt b/src/desafioVIII/readme.txt new file mode 100644 index 0000000..e69de29