Skip to content

Implementado funcionalidade para maquinda de cafe#20

Open
hugoogle wants to merge 57 commits into
movimentocodar:mainfrom
hugoogle:main
Open

Implementado funcionalidade para maquinda de cafe#20
hugoogle wants to merge 57 commits into
movimentocodar:mainfrom
hugoogle:main

Conversation

@hugoogle
Copy link
Copy Markdown

No description provided.

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Os arquivos da IDE (a pasta .idea e o arquivo .iml) podem ser adicionados no .gitignore.
Esses arquivos geralmente não são versionados.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

criado arquivo .gitignore para desconsiderar pasta e arquivo

Comment thread src/controller/ComprarController.java Outdated
return itemGratis;
}

private double getValorTotal() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Não sei se vale muito a pena esses métodos que tem uma linha só...
No fim das contas eles só repassam a chamada de outro método, não tem nenhuma regra e também não me parece melhorar legibilidade em geral.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Removido a classe comprarController foi criado um command para gerar o processo de pedido

Comment thread src/controller/ComprarController.java Outdated
else isPagamentoRealizado = pagamentoService.realizarPagamento(getValorTotal());


if (isPagamentoRealizado)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Pra if/else em Java é geralmente conveção sempre usar as chaves ({ e }) mesmo quando é uma linha só. Isso também melhora a legibilidade em geral.
Não sei se é o caso aqui, mas só o prepararBebida está no if. O atualizarEstoque e o que está pra frente não está.
Mas ele deveria atualizar o estoque se eu não preparei a bebida?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Alterado somente é atualizado o estoque apos finalizar a retirada da bebida pronta

Comment thread src/controller/ComprarController.java Outdated
Comment thread src/controller/ComprarController.java Outdated

public class ComprarController {

EstoqueService estoqueService = new EstoqueService();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A estrutura controller/service para separa as responsabilidades é uma boa ideia.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Verdade realizei algumas altereções nao sendo necessario mais a classe compraController removida!

Comment thread src/controller/ComprarController.java Outdated

}

private boolean isItemGratis(int opcao, int qtdCopos) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Esse método parece fazer mais coisas do que só verificar se é grátis. Talvez a regra de ser grátis também se encaixe melhor em outro lugar, tipo na própria bebida/item da máquina.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

hehe...nossa bem observado nao ficou bom nao hein... alterado!! agora passo a gerenciar se a bebida do metodo isNotGratis atraves de interface onde é possivel determina para cada bebida se é a mesma é gratis ou não

import model.Color;
import service.AbastecimentoService;

public class ControlerReabastecer {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Acho que vale a pena seguir o mesmo padrão de nomenclatura de antes. Tipo AbastecimentoController.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Verdade fora do padrao, porem removi a classe agora passo a gerencia o abastecimento da maquina apenas nas classe AbastecimentoController e AbastecimentoService

public class ControlerReabastecer {
private final AbastecimentoService abastecimentoService = new AbastecimentoService();

public void consultarEstoque() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Esse método faz mais do que consultar. Talvez um outro nome ou dividir as responsabilidades aqui.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Removido a classe não é mais necessaria!

if (necessidade != 0) {
abastecimentoService.reabastecerAMaquina();
} else {
System.out.println(Color.GREEN.getColorCode() + "\nMaquina se encontra abastecida!" + Color.RESET.getColorCode());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Criar um service pra impressão das mensagens pode ser uma boa.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Separei as mensagem fixa, dos fluxo acredito que ainda de para melhorar!

Comment thread src/menu/MenuAbastecer.java Outdated
public class MenuAbastecer {
private static final ControlerReabastecer controlerReabastecer = new ControlerReabastecer();

public static void abastecer(){
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Esse método também é um pouco estranho. Ele chama abastecer, mas dentro dele é uma chamada pra um método de nome consultar.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Modificado implementado opcao para confirmar ou nao o abastecimento.

hugoogle added 30 commits May 11, 2022 20:40
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