-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PR - Daniel - Pratica de Lambda #2
base: main
Are you sure you want to change the base?
PR - Daniel - Pratica de Lambda #2
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Parabéns por se comprometer a desenvolver as atividades, em uma analise geral o código está bem satisfatório, adicionei umas dicas para evoluir seu código.
OBS: Formulei a atividade VIII
incorretamente, queria realmente dizer:
VIII Mostra a categoria onde com os produtos mais caro;
VIII - Mostrar a categoria onde a soma dos produtos seja mais caro;
|
||
import java.math.BigDecimal; | ||
|
||
public class Produto { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dica: Legal a estrutura que você criou a classe (muitos sente dificuldade), uma dica seria para o atributo de categoria utilizar um enum
ia deixar seu código mais profissional ; )
} | ||
|
||
private static void atividadeA() { | ||
List<Produto> prodFiltroListA = produtoList.stream().filter(prod -> prod.getCategoria().equals("Tecnologia")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DICA para evitar erros como NullPointerException
seria interessante fazer o filtro assim:
.filter(prod -> "Tecnologia".equals(prod.getCategoria())
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Não sabia dessa, alterar a ordem... Significar que ele estaria comparando aquela String ("Tecnologia") que no caso sempre será existente, com a string do atributo de Produto (que pode ser um objeto ou null), certo?
|
||
} | ||
|
||
public static void listarProdutos(List<Produto> prodList) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DICA: Bastante legal esse método para reutilizar nos demais desafios, uma sugestão seria ter implementado o toString()
da classe Produto
pois o java olha esse método como padrão assim podia ser simplificado.
|
||
} | ||
|
||
private static void atividadeC() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Falta implementa o filtro somente com estoque;
Então, eu fiquei na dúvida nesta atividade VIII, no começo eu ia fazer por soma da maior categoria, mas ai me falaram que era a categoria com o produto de maior preço. |
Olha ai Deivid