Skip to content
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 - Fabio - Pratica de Lambda #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

FabioVLucena
Copy link

No description provided.

@DeividFrancis DeividFrancis changed the title feat: adiciona projeto desafio stream java PR - Fabio - Pratica de Lambda Oct 4, 2022
Copy link
Owner

@DeividFrancis DeividFrancis left a 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 junto com uns pontos para refazer a atividade.

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;

nomeProdutoList.forEach(s -> System.out.println(s));
}

private static void somarTodosOsProdutosDaCategoriaEsporte() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Falta o filtro pela categoria esporte

produtoList.add(new Produto(573, "Tapete Geometrico", 114.00, "Lazer", true));
}

public static void main(String[] args) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OBS Muito atencioso da sua parte a nomeclatura dos métodos e os comentários identificando cada atividade

produtoLog(primeiroProduto);
}

private static void listarProdutosPorOrdemAlfabetica() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A atividade esta propondo retorna uma lista de produto e não uma lista de nomes somente

});
}

private static void buscarCategoriaQueContemOsProdutosMaisCaros() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parabéns por essa forma de resolver a atividade, nunca tinha feito essa abordagem (ñ testei mas se funciona perfeito cara)

System.out.println(categoriaMaisCara.getKey() + " - " + categoriaMaisCara.getValue());
}

private static void listarIdDosProdutosEscolhidos() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nteressante sua forma de pensar, parabéns por resolver o problema mas tem uma limitação na lógica, imagine que esses ids são informados pelo usuário... seu código não ia suportar, uma forma seria:

List<Integer> ids = Arrays.asList(850, 403, 625);
List <Produtos> produtoTempList = produtoList.stream()
                                 .filter(p -> ids.contains(p.getId()))
				.toList();

produtoIdList.forEach(System.out::println);
}

private static void produtoLog(Produto produto) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parabéns pelo aproveitamento de código para imprimir dados do produto uma estratégia também aceita seria fazer o @Overrride na classe Produto do método .toString ex:

@Override
public String toString() {
	return id + " " + nome + " " + categoria + " " + valor + " " + temEstoque + "\n";
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants