From 2c42dfcd646f5ec169dce3f073d396fbe0063bbb Mon Sep 17 00:00:00 2001 From: Lilian Date: Mon, 13 Sep 2021 20:03:58 -0300 Subject: [PATCH 1/9] Teste --- .classpath | 10 ++++++++++ .idea/.gitignore | 3 +++ .idea/misc.xml | 6 ++++++ .idea/modules.xml | 8 ++++++++ .idea/runConfigurations.xml | 10 ++++++++++ .idea/vcs.xml | 6 ++++++ .project | 17 +++++++++++++++++ .settings/org.eclipse.jdt.core.prefs | 14 ++++++++++++++ MaquinadeCafe.iml | 12 ++++++++++++ bin/cafes/Acucar.class | Bin 0 -> 1452 bytes bin/cafes/Bebidas.class | Bin 0 -> 810 bytes bin/cafes/MaquinaDeCafe.class | Bin 0 -> 708 bytes bin/cafes/Pagamento.class | Bin 0 -> 264 bytes bin/cafes/Receitas.class | Bin 0 -> 541 bytes bin/cafes/ReservatorioDeAgua.class | Bin 0 -> 347 bytes bin/module-info.class | Bin 0 -> 152 bytes src/cafes/Acucar.java | 16 ++++++++++++++++ src/cafes/Bebidas.java | 21 +++++++++++++++++++++ src/cafes/MaquinaDeCafe.java | 27 +++++++++++++++++++++++++++ src/cafes/Pagamento.java | 12 ++++++++++++ src/cafes/Receitas.java | 22 ++++++++++++++++++++++ src/cafes/ReservatorioDeAgua.java | 5 +++++ src/module-info.java | 2 ++ 23 files changed, 191 insertions(+) create mode 100644 .classpath create mode 100644 .idea/.gitignore create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/runConfigurations.xml create mode 100644 .idea/vcs.xml create mode 100644 .project create mode 100644 .settings/org.eclipse.jdt.core.prefs create mode 100644 MaquinadeCafe.iml create mode 100644 bin/cafes/Acucar.class create mode 100644 bin/cafes/Bebidas.class create mode 100644 bin/cafes/MaquinaDeCafe.class create mode 100644 bin/cafes/Pagamento.class create mode 100644 bin/cafes/Receitas.class create mode 100644 bin/cafes/ReservatorioDeAgua.class create mode 100644 bin/module-info.class create mode 100644 src/cafes/Acucar.java create mode 100644 src/cafes/Bebidas.java create mode 100644 src/cafes/MaquinaDeCafe.java create mode 100644 src/cafes/Pagamento.java create mode 100644 src/cafes/Receitas.java create mode 100644 src/cafes/ReservatorioDeAgua.java create mode 100644 src/module-info.java diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..9f9bbb5 --- /dev/null +++ b/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..52b27e6 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..7594842 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..797acea --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.project b/.project new file mode 100644 index 0000000..122a93c --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + MaquinadeCafe + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..8aabe8d --- /dev/null +++ b/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=16 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=16 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=16 diff --git a/MaquinadeCafe.iml b/MaquinadeCafe.iml new file mode 100644 index 0000000..6b8ce9e --- /dev/null +++ b/MaquinadeCafe.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/bin/cafes/Acucar.class b/bin/cafes/Acucar.class new file mode 100644 index 0000000000000000000000000000000000000000..572f5253172980232cdc9162e5f915a4c1b2cbbf GIT binary patch literal 1452 zcmZ`&YflqV5IwiA-ELPNE2829MAWt@1);vE2tpC0fVe_Z{d8H@vZme2c9(=-;EypT zS~VJt#Kdp@DC6AQRw`&ebncnCbMDNU*`L3@>;uTbR1jj&E&klDWoE3v;+}#CL&pog z%QI!}mNI!as4&DpNR~%bv3v?~$`` z@S5p+j$0zyM1Ey`d1zy%u%0&=I-ebWR?S&u$94QEhHx^q!4R3PZrLiLDo!vcuI+9I z6|RBdq>fWKO-1CI_mjz^4=x^cr8eS}eMUzVF%^o6^Q6?vYOoXhcvGu66)wU9IusFB zRa|6xhehrs5hUR07AZ3V%k2Cj1E%B%!*=Yd$Gu zi_nCQ1Y+WJLq`WXNsfZ!+ABe2)ApY5&9W^ttXjOh!97P{>C_O$9nm|f+54}S8x7vo zq2n0o=WjbT2JK)%3@1vqzxI!b^(0eA^`bU+c{#9&q&t~9G%yW$JWw#t(A75Vy_#=V zbSz+zA{S681i47R5=H!1b^;s{Zebv(oh zL$>|;Y?;?;lSjL1Z&Z8=B&KFo1JAPO9U*+8vBe{zD{8`YN-p;Uk0JwYWFj;7cO_Gk z(_=K!Fnx#W^l7nV09o25X=!_;rDc(pmP199qu(q>>liYNu{u&_QK@6ZEUI;ko9~f*N2P>tlm0cbKm<>z?OW0-BJ_1O z3tu3Ag#3DX`0OX#PG9?o+(C9nLo5;?P9KCO8G0q7jwvY%W#S$Q6DGcC%rsduWErtW z(;tv~E1wm`#H90>q|qA}nly3T$1Hh-mN!UCF{9o(vc;uvdcT+xoiB&ae8$|>!))wN kTXEX4r6xz3iWCKC21|cN;XBy>^Fmmqn;|^HnzWC91M#^fnE(I) literal 0 HcmV?d00001 diff --git a/bin/cafes/Bebidas.class b/bin/cafes/Bebidas.class new file mode 100644 index 0000000000000000000000000000000000000000..71940cdffdfd9ce04069f8ebb88fe3a8163d7654 GIT binary patch literal 810 zcmZ`%+iuf95IyT8b?R4i&LF6Gk3ZqjglO2tD#NR=WgQIrQ>(8k%eTRC>**!>26 z2T)oB5+A@vA!ck#qy=7fW_D)Io;@=^e|`G_U8Xq66MeW%Z+~! z5}5CrP`^oseI373{U94;ndkRwr2YniE{}S`*y( zjQV%1z5nnPx6kpwJHzG~w!WbLiRvx1>8xij&Jh9+y+*jS9)!I`*pDdh<=A+PClt{u V8Ap+M%+ks{=2;>>PbsqS>^Dk(ta$(c literal 0 HcmV?d00001 diff --git a/bin/cafes/MaquinaDeCafe.class b/bin/cafes/MaquinaDeCafe.class new file mode 100644 index 0000000000000000000000000000000000000000..abc1e9b289518c3bd5e08d6fd4a0e74e4c31e2c2 GIT binary patch literal 708 zcmZuv+fLg+5Ivi?I5yjG2?@}amOD{ow^UZO&AAonS?VKGdei%U@r zMA)hRYMo18GdMln{^2LSh#B(r0dSDl7{+#0sPrB~)+;v|to^7hU1TxNVI$|@BPML* z8TkJ=j!BFW_DEgI;JX8cX^szRX`-$|d6aZpGX5i4fux&yBlYh@gj%&lTOP=NF3ou5w}V}*V%^3XnQxXF<>lCb$6#NiqXJsK z=)I*d4vV-$(hKiMV{jW$68rK{8Rtf9*-3}e+N6&D14bViPBBAgdMSzyWqT$Ec;x|Z zhs2dhQ8$>c++yk;-|n&U%I2Ee Z9Qo-OrqZB$$dpbiqe5H^o5YgA)?YEFmJa{` literal 0 HcmV?d00001 diff --git a/bin/cafes/Pagamento.class b/bin/cafes/Pagamento.class new file mode 100644 index 0000000000000000000000000000000000000000..b535e47c422e8e6df134d0da14f5fbceb5071fdf GIT binary patch literal 264 zcmZ8b%?`m}5S*=6seff|qY$48aqsSBIXJn)76n3J794-YEJ3B{34bUr2&y1g~Qo}?S) zp@4D~4vO+8(21IzkD!4$_F@HD}uB@6yiq`b202f3ZV?w@lAjq^8=K>%T$+ t(*+$!vebq!nM6TXl>gCy)4!o~m4yXQ(3~NLieU9KJHjQ9vIlX_ps znXdCBo`oo41|3@1hh@;Qg%m7- zOh?bu<6_!Z-ka<@+#=s`ZRvESr%fM_5r3@b{CQ_Lp=&Pq>MlH6-D{&w{YQ6cQo{uY zg_$qIH5(9xh&OdFsEME^gUbEZ@3WyEq@rhg`d$mHLQC^|csH|}G tv6h|iEO8k4y$GdAiZc`!kVBblbz^`EPTA4Q1VVd*%*YV&8M_e9{{Tf!W}yH8 literal 0 HcmV?d00001 diff --git a/bin/cafes/ReservatorioDeAgua.class b/bin/cafes/ReservatorioDeAgua.class new file mode 100644 index 0000000000000000000000000000000000000000..1e69c57fe0caa236a08691a07d1a3a2070047d51 GIT binary patch literal 347 zcmZ`!%Syvg5IvK`#-_0k6%=>wve}8-em|)+9ML3N4Ny^|}N-0)c<%P*FOu~t5gao=KbS5S<)s$eLoX!c(EKkIPjh+t|+g%WLd~BgZ7=$L1oBAb^ z;*q0N2)kh(b2{h3H29Zvs%KLYj>7*8o)f%>ye?w7GR>5OzZuRN`#9F+wniqs>Y%Nt waivUG(G*tu=a1jvjYsy^8~j)0E%f#6x4kwTJw2@l%J~~Th8QW*0IhoO2OjW9@c;k- literal 0 HcmV?d00001 diff --git a/bin/module-info.class b/bin/module-info.class new file mode 100644 index 0000000000000000000000000000000000000000..def849d40eb4483e5ba8c1073b627bd45a664234 GIT binary patch literal 152 zcmX^0Z`VEs1_m1jE_MbcMh5QO{FKt1RNc(Hw0uSeuHgLAqU2P!%$!t41_2}~y{yEt zL`DWSU$AOn26jdUUf;yR(#*WXlvL-$v{YdRPDTb!kSe{T#NyNj1_nl;EfB!Ozzk$C WF|aVO0% Date: Mon, 13 Sep 2021 20:28:57 -0300 Subject: [PATCH 2/9] Testando --- .classpath | 10 --- .idea/misc.xml | 4 +- .idea/modules.xml | 2 +- .idea/vcs.xml | 2 +- .project | 17 ---- .settings/org.eclipse.jdt.core.prefs | 14 --- MaquinadeCafe.iml => DesafioMaquinaDeCafe.iml | 5 +- README.md | 85 ------------------ bin/cafes/Acucar.class | Bin 1452 -> 0 bytes bin/cafes/Bebidas.class | Bin 810 -> 0 bytes bin/cafes/MaquinaDeCafe.class | Bin 708 -> 0 bytes bin/cafes/Pagamento.class | Bin 264 -> 0 bytes bin/cafes/Receitas.class | Bin 541 -> 0 bytes bin/cafes/ReservatorioDeAgua.class | Bin 347 -> 0 bytes bin/module-info.class | Bin 152 -> 0 bytes .../DesafioMaquinaDeCafe/cafes/Acucar.class | Bin 0 -> 1487 bytes .../DesafioMaquinaDeCafe/cafes/Bebidas.class | Bin 0 -> 1004 bytes .../cafes/MaquinaDeCafe.class | Bin 0 -> 671 bytes .../cafes/Pagamento.class | Bin 0 -> 264 bytes .../DesafioMaquinaDeCafe/cafes/Receitas.class | Bin 0 -> 541 bytes .../cafes/ReservatorioDeAgua.class | Bin 0 -> 343 bytes src/cafes/Bebidas.java | 13 +-- src/cafes/MaquinaDeCafe.java | 18 ++-- src/module-info.java | 2 - 24 files changed, 24 insertions(+), 148 deletions(-) delete mode 100644 .classpath delete mode 100644 .project delete mode 100644 .settings/org.eclipse.jdt.core.prefs rename MaquinadeCafe.iml => DesafioMaquinaDeCafe.iml (66%) delete mode 100644 README.md delete mode 100644 bin/cafes/Acucar.class delete mode 100644 bin/cafes/Bebidas.class delete mode 100644 bin/cafes/MaquinaDeCafe.class delete mode 100644 bin/cafes/Pagamento.class delete mode 100644 bin/cafes/Receitas.class delete mode 100644 bin/cafes/ReservatorioDeAgua.class delete mode 100644 bin/module-info.class create mode 100644 out/production/DesafioMaquinaDeCafe/cafes/Acucar.class create mode 100644 out/production/DesafioMaquinaDeCafe/cafes/Bebidas.class create mode 100644 out/production/DesafioMaquinaDeCafe/cafes/MaquinaDeCafe.class create mode 100644 out/production/DesafioMaquinaDeCafe/cafes/Pagamento.class create mode 100644 out/production/DesafioMaquinaDeCafe/cafes/Receitas.class create mode 100644 out/production/DesafioMaquinaDeCafe/cafes/ReservatorioDeAgua.class delete mode 100644 src/module-info.java diff --git a/.classpath b/.classpath deleted file mode 100644 index 9f9bbb5..0000000 --- a/.classpath +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/.idea/misc.xml b/.idea/misc.xml index 52b27e6..15cec4b 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - - + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml index 7594842..e763463 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,7 +2,7 @@ - + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml index 35eb1dd..94a25f7 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/.project b/.project deleted file mode 100644 index 122a93c..0000000 --- a/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - MaquinadeCafe - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 8aabe8d..0000000 --- a/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,14 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=16 -org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=16 -org.eclipse.jdt.core.compiler.debug.lineNumber=generate -org.eclipse.jdt.core.compiler.debug.localVariable=generate -org.eclipse.jdt.core.compiler.debug.sourceFile=generate -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning -org.eclipse.jdt.core.compiler.release=enabled -org.eclipse.jdt.core.compiler.source=16 diff --git a/MaquinadeCafe.iml b/DesafioMaquinaDeCafe.iml similarity index 66% rename from MaquinadeCafe.iml rename to DesafioMaquinaDeCafe.iml index 6b8ce9e..c90834f 100644 --- a/MaquinadeCafe.iml +++ b/DesafioMaquinaDeCafe.iml @@ -1,12 +1,11 @@ - - + - + \ No newline at end of file diff --git a/README.md b/README.md deleted file mode 100644 index e9f3e4b..0000000 --- a/README.md +++ /dev/null @@ -1,85 +0,0 @@ -# iniciante-java-oo-2021 - -# Conteúdo - -Plano de estudos com cursos, artigos e vídeos com o conteúdo do módulo "Back-end - Java e Orientação a Objetos Básico" - -- [Plano de estudo](https://cursos.alura.com.br/backend-java-vnsueda-1622331668115-p164413) - -Conteúdo adicional - -- https://www.w3schools.com/java/default.asp - -# Desafio - -Desafio do módulo "Back-end - Java e Orientação a Objetos Básico" do Movimento Codar 2021. Pratique Java e Orientação a Objetos construindo a sua Máquina de Café! - -## Pré-requisitos - -- Instale o [Git](https://git-scm.com/). -- Faça um fork desse projeto clicando no botão `Fork` no canto superior direito da página, conforme a imagem abaixo. - -![Realizando o fork](https://docs.github.com/assets/images/help/repository/fork_button.jpg) - -- Acesse o fork que você criou e faça o clone para a sua máquina. Clique primeiro no botão `Code` e depois copie a URL. - -Copiando a URL - -- Realize o clone com o comando `git clone` + a URL copiada. - -- Abra o projeto na sua IDE ou editor de texto preferido. Se não tiver um recomendamos o [IntelliJ IDEA](https://www.jetbrains.com/pt-br/idea/). - -## Resolvendo o desafio - -Seu desafio é utilizar seus conhecimentos de Java e Orientação a Objetos para construir uma máquina de café. - -### Selecionando uma opção - -As seguintes opções devem estar disponíveis para seleção: - -- Café - R$0.50 -- Café com Leite - R$1.00 -- Capuccino - R$1.50 -- Chá de Limão - R$1.00 -- Água Quente - Grátis -- Nível de açucar - - Nível Padrão = 3, podendo variar de 0 a 5 - - Deverá ser ignorado quando a opção escolhida for "Água Quente" -- Adicionar crédito - - Dinheiro - - Qualquer Cédula/Nota válida no Brasil em 2021 - - Cartão de Débito - - Qualquer valor maior que zero - - -Essa máquina não devolve troco, só recebe créditos e os desconta ao selecionar uma bebida. - -### Preparando a bebida - -Para simular a preparação da bebida solicitada, você deverá demonstrar toda a preparação e seguir as seguintes receitas: - -- Água Quente = Água do reservatório + Processo para ferver a água -- Café = Água Quente + Pó de café + Filtro -- Café com Leite = Água Quente + Pó de café + Leite em Pó + Filtro -- Capuccino = Água Quente + Café em pó + Leite em Pó + Chocolate em Pó + Filtro -- Chá de Limão = Água Quente + Chá em pó + Filtro - -### Avisos - -- Crie os arquivos e faça a organização do projeto conforme achar necessário. -- A forma como irá demonstrar as informações e solicitar entrada do usuário poderá ser via console. Fique à vontade para fazer de outra forma se preferir. - -## Desafio extra - -1. Algumas pessoas ficaram bravas com o lance de não devolver troco... Use a sua criatividade ao criar e implementar uma solução na Máquina de Café para resolver este problema. -2. Considere que a máquina tem um reservatório de 1L de água e cada bebida retirada sempre usará 50ml, quando não houver água disponível informe na saída que a máquina precisa ser reabastecida com água. - -## Submetendo a solução dos desafios - -Ao terminar crie um `Pull Request` com a sua solução. - -Para isso clique em `Contribute` e `Open Pull Request`. Depois basta confirmar a operação. - -Criando PR - -## :trophy: Finalizaram o desafio :trophy: diff --git a/bin/cafes/Acucar.class b/bin/cafes/Acucar.class deleted file mode 100644 index 572f5253172980232cdc9162e5f915a4c1b2cbbf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1452 zcmZ`&YflqV5IwiA-ELPNE2829MAWt@1);vE2tpC0fVe_Z{d8H@vZme2c9(=-;EypT zS~VJt#Kdp@DC6AQRw`&ebncnCbMDNU*`L3@>;uTbR1jj&E&klDWoE3v;+}#CL&pog z%QI!}mNI!as4&DpNR~%bv3v?~$`` z@S5p+j$0zyM1Ey`d1zy%u%0&=I-ebWR?S&u$94QEhHx^q!4R3PZrLiLDo!vcuI+9I z6|RBdq>fWKO-1CI_mjz^4=x^cr8eS}eMUzVF%^o6^Q6?vYOoXhcvGu66)wU9IusFB zRa|6xhehrs5hUR07AZ3V%k2Cj1E%B%!*=Yd$Gu zi_nCQ1Y+WJLq`WXNsfZ!+ABe2)ApY5&9W^ttXjOh!97P{>C_O$9nm|f+54}S8x7vo zq2n0o=WjbT2JK)%3@1vqzxI!b^(0eA^`bU+c{#9&q&t~9G%yW$JWw#t(A75Vy_#=V zbSz+zA{S681i47R5=H!1b^;s{Zebv(oh zL$>|;Y?;?;lSjL1Z&Z8=B&KFo1JAPO9U*+8vBe{zD{8`YN-p;Uk0JwYWFj;7cO_Gk z(_=K!Fnx#W^l7nV09o25X=!_;rDc(pmP199qu(q>>liYNu{u&_QK@6ZEUI;ko9~f*N2P>tlm0cbKm<>z?OW0-BJ_1O z3tu3Ag#3DX`0OX#PG9?o+(C9nLo5;?P9KCO8G0q7jwvY%W#S$Q6DGcC%rsduWErtW z(;tv~E1wm`#H90>q|qA}nly3T$1Hh-mN!UCF{9o(vc;uvdcT+xoiB&ae8$|>!))wN kTXEX4r6xz3iWCKC21|cN;XBy>^Fmmqn;|^HnzWC91M#^fnE(I) diff --git a/bin/cafes/Bebidas.class b/bin/cafes/Bebidas.class deleted file mode 100644 index 71940cdffdfd9ce04069f8ebb88fe3a8163d7654..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 810 zcmZ`%+iuf95IyT8b?R4i&LF6Gk3ZqjglO2tD#NR=WgQIrQ>(8k%eTRC>**!>26 z2T)oB5+A@vA!ck#qy=7fW_D)Io;@=^e|`G_U8Xq66MeW%Z+~! z5}5CrP`^oseI373{U94;ndkRwr2YniE{}S`*y( zjQV%1z5nnPx6kpwJHzG~w!WbLiRvx1>8xij&Jh9+y+*jS9)!I`*pDdh<=A+PClt{u V8Ap+M%+ks{=2;>>PbsqS>^Dk(ta$(c diff --git a/bin/cafes/MaquinaDeCafe.class b/bin/cafes/MaquinaDeCafe.class deleted file mode 100644 index abc1e9b289518c3bd5e08d6fd4a0e74e4c31e2c2..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 708 zcmZuv+fLg+5Ivi?I5yjG2?@}amOD{ow^UZO&AAonS?VKGdei%U@r zMA)hRYMo18GdMln{^2LSh#B(r0dSDl7{+#0sPrB~)+;v|to^7hU1TxNVI$|@BPML* z8TkJ=j!BFW_DEgI;JX8cX^szRX`-$|d6aZpGX5i4fux&yBlYh@gj%&lTOP=NF3ou5w}V}*V%^3XnQxXF<>lCb$6#NiqXJsK z=)I*d4vV-$(hKiMV{jW$68rK{8Rtf9*-3}e+N6&D14bViPBBAgdMSzyWqT$Ec;x|Z zhs2dhQ8$>c++yk;-|n&U%I2Ee Z9Qo-OrqZB$$dpbiqe5H^o5YgA)?YEFmJa{` diff --git a/bin/cafes/Pagamento.class b/bin/cafes/Pagamento.class deleted file mode 100644 index b535e47c422e8e6df134d0da14f5fbceb5071fdf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 264 zcmZ8b%?`m}5S*=6seff|qY$48aqsSBIXJn)76n3J794-YEJ3B{34bUr2&y1g~Qo}?S) zp@4D~4vO+8(21IzkD!4$_F@HD}uB@6yiq`b202f3ZV?w@lAjq^8=K>%T$+ t(*+$!vebq!nM6TXl>gCy)4!o~m4yXQ(3~NLieU9KJHjQ9vIlX_ps znXdCBo`oo41|3@1hh@;Qg%m7- zOh?bu<6_!Z-ka<@+#=s`ZRvESr%fM_5r3@b{CQ_Lp=&Pq>MlH6-D{&w{YQ6cQo{uY zg_$qIH5(9xh&OdFsEME^gUbEZ@3WyEq@rhg`d$mHLQC^|csH|}G tv6h|iEO8k4y$GdAiZc`!kVBblbz^`EPTA4Q1VVd*%*YV&8M_e9{{Tf!W}yH8 diff --git a/bin/cafes/ReservatorioDeAgua.class b/bin/cafes/ReservatorioDeAgua.class deleted file mode 100644 index 1e69c57fe0caa236a08691a07d1a3a2070047d51..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 347 zcmZ`!%Syvg5IvK`#-_0k6%=>wve}8-em|)+9ML3N4Ny^|}N-0)c<%P*FOu~t5gao=KbS5S<)s$eLoX!c(EKkIPjh+t|+g%WLd~BgZ7=$L1oBAb^ z;*q0N2)kh(b2{h3H29Zvs%KLYj>7*8o)f%>ye?w7GR>5OzZuRN`#9F+wniqs>Y%Nt waivUG(G*tu=a1jvjYsy^8~j)0E%f#6x4kwTJw2@l%J~~Th8QW*0IhoO2OjW9@c;k- diff --git a/bin/module-info.class b/bin/module-info.class deleted file mode 100644 index def849d40eb4483e5ba8c1073b627bd45a664234..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 152 zcmX^0Z`VEs1_m1jE_MbcMh5QO{FKt1RNc(Hw0uSeuHgLAqU2P!%$!t41_2}~y{yEt zL`DWSU$AOn26jdUUf;yR(#*WXlvL-$v{YdRPDTb!kSe{T#NyNj1_nl;EfB!Ozzk$C WF|aVO0%m5l2`YdryQEH9Aa&B#sFPNOB4Yf4fXqSO6S7kjw}NHjyGhnKo&3{V82N~UKXK>{ zSpv7{n^Jdi@}IzJ*)oV6G90WX7`UhyUFr);QJ(jbWWK-NXH;z5<9wDUel=fC%+P#IUP68e8Smxh%57a!kkrRTA3G;=0#=d%DkL1uPAdsnWeOO oRhb!OUf0ZdW$yiq#djEC{n|6rl~xHnA$?+zLJ#qX?qjI@1#m7T)c^nh literal 0 HcmV?d00001 diff --git a/out/production/DesafioMaquinaDeCafe/cafes/Bebidas.class b/out/production/DesafioMaquinaDeCafe/cafes/Bebidas.class new file mode 100644 index 0000000000000000000000000000000000000000..373567d0e25f4e4c5a6e7add8ecc7c47fbc11443 GIT binary patch literal 1004 zcmaJoWp zhMLBN2Y-M+%6NCT2_HqX*}3=bo;mm2oAdk6#V-K+*fWtp(m={W8X1Q9Q+~#)F85BV z?>nc$(F~b==}G;XAz7}pbI2lRz_c&}i(%H`pG8nT5FOd&0YgG|8CWAk%~{A}o+0I_ zfnX>!FPU4~m)=P&L=`M7;4XvV3r9%JNkKE_{1AT#BG^3(OA*;Xc%uR-U$(Gkf+|wjwuRPsxLOqdNt4t#p(nFG>Xo@!sTjj98S4LZU<<{dX0TRGfqb6I>mh6pQvxFne_j!`>ca*4`Q8&UY-@7q}1nz~VQ;Bv7Pt1sOVL=$3^XW-&+40`*)c z_6_=D$9#B%$5at>q>Dvas4P@ljI2k@bc zvjt;J=*3KDX6M`aXTQGRKLPAv$3Ox}9h!+0(hT`K{>UAV`)%j6c_-Y6A-yMk8SOJ9 z?Q%m$hGD|xH=^sD3s=a9cMa$;RR0)5%D%cPH?kPVgpQnvJSP7^>(AXtbchx72t8ek zuakju7D_*=N1@=IY6b;{v0LGJLFp+7y_SJ#6m`s)n8h4JVMG&yey5G$Irzye<-t;JA)dH7$4IWAr z50hGSE4xa?2v(I~9WH5{qJ2GT9;)-OP3?sdWrp$Lc7G?!4=?#$I`NHq&KoTXg=HLJ!)+owi9UGKU&6m(( z=-dbNOHF%2w)P6svig`J-^ctP(4wOXYaj!QAhYyWqD*lBz$UgRGLXYIY{D~?DNdmB E1BlO!yZ`_I literal 0 HcmV?d00001 diff --git a/out/production/DesafioMaquinaDeCafe/cafes/Pagamento.class b/out/production/DesafioMaquinaDeCafe/cafes/Pagamento.class new file mode 100644 index 0000000000000000000000000000000000000000..51e9003013c6c7f07502599ab871cb32c43783c4 GIT binary patch literal 264 zcmZ8b%TB{U3>@dt&=5%B54aT$><18WLFy@LkwCdSVJTZBSt*bHS5HVB_<(*C!W&f_ zu%)qQEZcMZ`T7QsVG+ZFA0bE(Vn$f(c+aZlcB?k!PFDkAmYLQJj|6{tTSPb`q!qvG zUOn@c8{H0;5Ios8ErZ;&dObF!?q0d9MY+yx#dX1*ar`6(!-we!SNXp?4}|!|j$Nf! z#w}m|eYkhFaDzzPx*$pMD>xUXCJuympP+*X9%4Z^27H_gCQ~0uy$~j+1wEv{JY6*z literal 0 HcmV?d00001 diff --git a/out/production/DesafioMaquinaDeCafe/cafes/Receitas.class b/out/production/DesafioMaquinaDeCafe/cafes/Receitas.class new file mode 100644 index 0000000000000000000000000000000000000000..17aa577eda0f5dfc039340b09222ac241cf7ec53 GIT binary patch literal 541 zcmY*WO;5r=5Pe$;m0CUp{J;;qK@XC6m6#ZeiAkeI4F_&ZSzt+NV`=$c9*Btte}F&A zI9qE1mw7vH=FMc@e*b)a0qCJ+LPN%YZXt^tLwU|uyz6m)+I<|&g&Q&CdeWECHAAM| z8RW5pyaCg~E-Z$k%O_&leHN~e5nq!2E#`hC$9ybq#mzM44D4QsiWW*JGnf+*u0)uY zhN@Jxu%}A7iS(i{V5n{mc?$ZpgQ2oXI<$_s`X<+(1#aMR#c%h@1*f6e_Hfu4FzEeY zOf4lx`r;v8j70d#M;((*vD&B u-V@mo#Rf@$0(2B%lHF=#4HYzrZT$_vF-|C>QAw30FSSymRi~6`IQs<`2xj;I literal 0 HcmV?d00001 diff --git a/out/production/DesafioMaquinaDeCafe/cafes/ReservatorioDeAgua.class b/out/production/DesafioMaquinaDeCafe/cafes/ReservatorioDeAgua.class new file mode 100644 index 0000000000000000000000000000000000000000..78aa813b939d513e9957fb84efeebcc8089ea27c GIT binary patch literal 343 zcmZ`#O-sW-5Pg%x#>Qw{6%=pYva+xhuZV8>SuCzTN_y>ox zE>_VE5yesYieyy)nwkXY`SW>vbx|x{Ze#J2&Se`gkGvEb Date: Mon, 13 Sep 2021 23:57:59 -0300 Subject: [PATCH 3/9] Desafio em andamento --- .../DesafioMaquinaDeCafe/cafes/Acucar.class | Bin 1487 -> 1486 bytes .../DesafioMaquinaDeCafe/cafes/Bebida.class | Bin 0 -> 1219 bytes .../DesafioMaquinaDeCafe/cafes/Bebidas.class | Bin 1004 -> 0 bytes .../cafes/MaquinaDeCafe.class | Bin 671 -> 4963 bytes .../DesafioMaquinaDeCafe/cafes/Receitas.class | Bin 541 -> 1336 bytes .../cafes/ReservatorioDeAgua.class | Bin 343 -> 706 bytes src/cafes/Acucar.java | 23 ++-- src/cafes/Bebida.java | 38 +++++++ src/cafes/Bebidas.java | 22 ---- src/cafes/MaquinaDeCafe.java | 107 ++++++++++++++---- src/cafes/Pagamento.java | 8 -- src/cafes/Receitas.java | 67 +++++++---- src/cafes/ReservatorioDeAgua.java | 14 ++- 13 files changed, 197 insertions(+), 82 deletions(-) create mode 100644 out/production/DesafioMaquinaDeCafe/cafes/Bebida.class delete mode 100644 out/production/DesafioMaquinaDeCafe/cafes/Bebidas.class create mode 100644 src/cafes/Bebida.java delete mode 100644 src/cafes/Bebidas.java diff --git a/out/production/DesafioMaquinaDeCafe/cafes/Acucar.class b/out/production/DesafioMaquinaDeCafe/cafes/Acucar.class index 67c09e75747de35591531bed1ad2ed1347193a66..a71d500f6c825c2e3cae49a5695f2bd1b841e5bf 100644 GIT binary patch delta 21 dcmX@leU5v>KSmCog8b6L(!*;vvooDw1^{Dr2&e!6 delta 22 ecmX@deV%*6KSoa8g8b6L()auKZf0XT!3+R!`U#`} diff --git a/out/production/DesafioMaquinaDeCafe/cafes/Bebida.class b/out/production/DesafioMaquinaDeCafe/cafes/Bebida.class new file mode 100644 index 0000000000000000000000000000000000000000..4e63fda997e7cc50d292a0f6a68243f4b48b3f85 GIT binary patch literal 1219 zcmZuv?M@R>5IwhD*tRU+R6r1+fV35;3VtMQNYuupNkt?llC&wvjC-}RbBiJG!7j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)W2Q(7#J9A7(^y=MG6W8mL}$vWTqshq`IU!rk5s8Y>Jqi%4opJz`)JG S160R2c^;!LD+2=)gD?P$qY%Xa diff --git a/src/cafes/Acucar.java b/src/cafes/Acucar.java index e634fe4..205be30 100644 --- a/src/cafes/Acucar.java +++ b/src/cafes/Acucar.java @@ -1,16 +1,15 @@ package cafes; public enum Acucar { - Nivel0("nenhuma"),Nivel1("pouqussima"),Nivel2("pouca"),Nivel3("normal"),Nivel4("muito"),Nivel5("bastante"); - - private String quantidadeDeAcucar; - - private Acucar(String quantidade){ - this.quantidadeDeAcucar = quantidade; - } - - public String getQuantidadeDeAcucar() { - return this.quantidadeDeAcucar; - } + Nivel0("nenhuma"),Nivel1("pouquíssima"),Nivel2("pouca"),Nivel3("normal"),Nivel4("muito"),Nivel5("bastante"); -} \ No newline at end of file + private String quantidadeDeAcucar; + + private Acucar(String quantidade){ + this.quantidadeDeAcucar = quantidade; + } + + public String getQuantidadeDeAcucar() { + return this.quantidadeDeAcucar; + } +} diff --git a/src/cafes/Bebida.java b/src/cafes/Bebida.java new file mode 100644 index 0000000..356e8da --- /dev/null +++ b/src/cafes/Bebida.java @@ -0,0 +1,38 @@ +package cafes; +import java.util.ArrayList; + +public class Bebida { + private int id; + private String nome; + Receitas receita; + private double preco; + private static ArrayList menu = new ArrayList(); + + public Bebida(){ + + } + + public Bebida(int id, String nome, Receitas receita, double preco) { + this.id = id; + this.nome = nome; + this.receita = receita; + this.preco = preco; + Bebida.menu.add(this); + } + + public static ArrayList getMenu() { + return menu; + } + + public String getNome() { + return nome; + } + + public int getId() { + return id; + } + + public double getPreco() { + return preco; + } +} diff --git a/src/cafes/Bebidas.java b/src/cafes/Bebidas.java deleted file mode 100644 index afd9b18..0000000 --- a/src/cafes/Bebidas.java +++ /dev/null @@ -1,22 +0,0 @@ -package cafes; - -public class Bebidas { - - private int id; - private String nome; - Receitas receita; - private double preco;// obj novo? - private static String menu; - - //construtor - public Bebidas(int id, String nome, Receitas receita) { - this.id = id; - this.nome = nome; - this.receita = receita; - Bebidas.menu += this; //ser� que funciona como um array ? - } - - - - -} diff --git a/src/cafes/MaquinaDeCafe.java b/src/cafes/MaquinaDeCafe.java index 52448cb..6c315d2 100644 --- a/src/cafes/MaquinaDeCafe.java +++ b/src/cafes/MaquinaDeCafe.java @@ -1,31 +1,98 @@ package cafes; +import java.util.Scanner; +import java.math.*; + public class MaquinaDeCafe { + public static void main(String[] args) { + Scanner cafeScanner = new Scanner(System.in); + Bebida BebidasMenu = new Bebida(); + ReservatorioDeAgua reservaDeAguaAtual = new ReservatorioDeAgua(); + + Receitas ReceitaDeCafe = new Receitas (true, true); + ReceitaDeCafe.setQuantidadeDePoCafe(10); + + Receitas ReceitaDeCafeComLeite = new Receitas (true, true); + ReceitaDeCafeComLeite.setQuantidadeDePoCafe(5); + ReceitaDeCafeComLeite.setQuantidadeDeLeite(10); + + Receitas ReceitaDeCappuccino = new Receitas (true, true); + ReceitaDeCappuccino.setQuantidadeDePoCafe(5); + ReceitaDeCappuccino.setQuantidadeDeLeite(5); + ReceitaDeCappuccino.setQuantidadeDeChocolate(5); + + Receitas ReceitaDeChaDeLimao = new Receitas (true, true); + ReceitaDeChaDeLimao.setQuantidadeDeLimao(10); + + Receitas ReceitaDeAguaQuente = new Receitas(true, false); + + Bebida Cafe = new Bebida(0,"Café",ReceitaDeCafe, 0.50); + Bebida CafeComLeite = new Bebida(1,"Café com leite", ReceitaDeCafeComLeite, 1.00); + Bebida Capuccino = new Bebida(2,"Capuccino",ReceitaDeCappuccino,1.50); + Bebida ChaDeLimao = new Bebida(3,"Chá de limão", ReceitaDeChaDeLimao, 1.00); + Bebida AguaQuente = new Bebida(4, "Água Quente", ReceitaDeAguaQuente, 0.00); + + if(reservaDeAguaAtual.getQuantidadeDeAguaNoReservatorio() > 50){ + Inicializacao(cafeScanner, reservaDeAguaAtual.getQuantidadeDeAguaNoReservatorio(), BebidasMenu); + } else { + String keyRepor = "repor"; + String repor = ""; + do + { + repor = getScanner(cafeScanner, "Por favor, digite 'repor' para repor quantidade de água"); + } while(!keyRepor.equals(repor.toLowerCase())); + + reservaDeAguaAtual.reporQuantidadeDeAguaNoReservatorio(); + System.out.println("Reservatório de água completo!"); + Inicializacao(cafeScanner, reservaDeAguaAtual.getQuantidadeDeAguaNoReservatorio(), BebidasMenu); + } + + + } + + private static void Inicializacao(Scanner cafeScanner, int AtualQuantidadeDeAgua, Bebida BebidasMenu) { + + String msgReservatorioDeAgua = AtualQuantidadeDeAgua > 50? "suficiente para " + (AtualQuantidadeDeAgua /50) + " bebidas" : "vazios, favor repor"; + + System.out.println("Seja bem-vindo a máquina de café 2021!"); + System.out.println("Atenção: essa máquina não devolve troco."); + System.out.println("Reservatórios de água " + msgReservatorioDeAgua); + + if(AtualQuantidadeDeAgua > 50){ + for (int i = 0; i < BebidasMenu.getMenu().size(); i++) { + System.out.println(BebidasMenu.getMenu().get(i).getId() + " " + BebidasMenu.getMenu().get(i).getNome() + ", preço: " + (BebidasMenu.getMenu().get(i).getPreco() == 0? "grátis" : moedaEmReais(BebidasMenu.getMenu().get(i).getPreco()))); + } + + String bebidaEscolhida = ""; + do { + bebidaEscolhida = getScanner(cafeScanner, "Digite o número da bebida escolhida"); + } while(bebidaEncontrada(bebidaEscolhida, BebidasMenu) == -1); + System.out.println("A bebida escolhida foi " + BebidasMenu.getMenu().get(Integer.parseInt(bebidaEscolhida)).getNome()); - public static void main(String[] args) { - Receitas ReceitaDeCafe = new Receitas(true, true); + } + } - System.out.println("hello world"); + private static int bebidaEncontrada(String bebidaEscolhida, Bebida BebidasMenu){ + for(int i = 0; i < BebidasMenu.getMenu().size(); i++){ + int IDdasBebidasDoMenu = BebidasMenu.getMenu().get(i).getId(); + if(String.valueOf(IDdasBebidasDoMenu).equals(bebidaEscolhida)){ + return IDdasBebidasDoMenu; + } + } + return -1; + } - } + private static String moedaEmReais(double valor) { + BigDecimal b = new BigDecimal(valor); + return "R$ " + b.setScale(2, RoundingMode.HALF_EVEN); + } - //cadastrar receitas e bebidas - - //iniciar mostrando help - avisar que nao tem troco - opcao verificar se tem agua, menu, **valor de voucher? - //retornar menu com preco - //verificar se tem agua - - - /*chamar menu com preco - retorna listra - escolher opcao - retorna se tem agua - retornar preco e opcoes de pgto - cartao e qtd de notas e moedas - pagar - retornar se falta ou tem troco - decidir quantidade de acucar 0 a 5 se n�o for agua - preparar - liberar*/ - //retornar voucher de troco - + private static String getScanner(Scanner cafeScanner, String mensagem) { + System.out.println(mensagem); + String entry = cafeScanner.nextLine(); + return entry; + } } diff --git a/src/cafes/Pagamento.java b/src/cafes/Pagamento.java index a7d0a69..8683f2b 100644 --- a/src/cafes/Pagamento.java +++ b/src/cafes/Pagamento.java @@ -1,12 +1,4 @@ package cafes; public class Pagamento { -// String tipoDePagamento = "cartao debito ou notas"; //eventualmente voucher de vale crditos -// double valorASerPago; -// -// -// calcular quantidade de cdula ou nota - //calcular valor de cupom de valor - - } diff --git a/src/cafes/Receitas.java b/src/cafes/Receitas.java index 2dbd1e0..50b197b 100644 --- a/src/cafes/Receitas.java +++ b/src/cafes/Receitas.java @@ -1,22 +1,51 @@ package cafes; public class Receitas { - private int quantidadeDeAgua; - private int quantidadeDePoCafe; - private int quantidadeDeLeite; - private int quantidadeDeChocolate; - private int quantidadeDeLimao; - private boolean ferverAgua; - private boolean filtro; - - - public Receitas(boolean ferverAgua, boolean filtro) { - this.quantidadeDeAgua = 50; - this.ferverAgua = ferverAgua; - this.filtro = filtro; - } - - - //metodo de processo da receita - -} \ No newline at end of file + private int quantidadeDeAgua; + private int quantidadeDePoCafe; + private int quantidadeDeLeite; + private int quantidadeDeChocolate; + private int quantidadeDeLimao; + private boolean ferverAgua; + private boolean filtro; + + public Receitas(boolean ferverAgua, boolean filtro) { + this.quantidadeDeAgua = 50; + this.ferverAgua = ferverAgua; + this.filtro = filtro; + } + + public int getQuantidadeDePoCafe() { + return quantidadeDePoCafe; + } + + public void setQuantidadeDePoCafe(int quantidadeDePoCafe) { + this.quantidadeDePoCafe = quantidadeDePoCafe; + } + + public int getQuantidadeDeLeite() { + return quantidadeDeLeite; + } + + public void setQuantidadeDeLeite(int quantidadeDeLeite) { + this.quantidadeDeLeite = quantidadeDeLeite; + } + + public int getQuantidadeDeChocolate() { + return quantidadeDeChocolate; + } + + public void setQuantidadeDeChocolate(int quantidadeDeChocolate) { + this.quantidadeDeChocolate = quantidadeDeChocolate; + } + + public int getQuantidadeDeLimao() { + return quantidadeDeLimao; + } + + public void setQuantidadeDeLimao(int quantidadeDeLimao) { + this.quantidadeDeLimao = quantidadeDeLimao; + } + + //metodo de processo da receita +} diff --git a/src/cafes/ReservatorioDeAgua.java b/src/cafes/ReservatorioDeAgua.java index 2a41e56..350d26d 100644 --- a/src/cafes/ReservatorioDeAgua.java +++ b/src/cafes/ReservatorioDeAgua.java @@ -1,5 +1,17 @@ package cafes; public class ReservatorioDeAgua { - int QuantidadeDeAgua = 1000; + private int QuantidadeDeAguaNoReservatorio = 1000; + + public int getQuantidadeDeAguaNoReservatorio() { + return QuantidadeDeAguaNoReservatorio; + } + + public void atualizarNiveisDeAgua(int quantidadeDeAguaUtilizada) { + QuantidadeDeAguaNoReservatorio = QuantidadeDeAguaNoReservatorio - quantidadeDeAguaUtilizada; + } + + public void reporQuantidadeDeAguaNoReservatorio() { + QuantidadeDeAguaNoReservatorio = 1000; + } } From 9e3e75abe2d2f18182dd8796404b20c526d27f55 Mon Sep 17 00:00:00 2001 From: Lilian Date: Wed, 15 Sep 2021 19:20:04 -0300 Subject: [PATCH 4/9] Desafio finalizado --- .idea/uiDesigner.xml | 124 +++++++++ .../DesafioMaquinaDeCafe/cafes/Acucar.class | Bin 1486 -> 1929 bytes .../DesafioMaquinaDeCafe/cafes/Bebida.class | Bin 1219 -> 1217 bytes .../cafes/MaquinaDeCafe.class | Bin 4963 -> 11277 bytes .../cafes/NotasEMoedas.class | Bin 0 -> 2485 bytes .../cafes/Pagamento.class | Bin 264 -> 0 bytes .../DesafioMaquinaDeCafe/cafes/Receita.class | Bin 0 -> 3213 bytes .../DesafioMaquinaDeCafe/cafes/Receitas.class | Bin 1336 -> 0 bytes src/cafes/Acucar.java | 16 +- src/cafes/Bebida.java | 4 +- src/cafes/MaquinaDeCafe.java | 263 ++++++++++++++++-- src/cafes/NotasEMoedas.java | 65 +++++ src/cafes/Pagamento.java | 4 - src/cafes/Receita.java | 72 +++++ src/cafes/Receitas.java | 51 ---- 15 files changed, 522 insertions(+), 77 deletions(-) create mode 100644 .idea/uiDesigner.xml create mode 100644 out/production/DesafioMaquinaDeCafe/cafes/NotasEMoedas.class delete mode 100644 out/production/DesafioMaquinaDeCafe/cafes/Pagamento.class create mode 100644 out/production/DesafioMaquinaDeCafe/cafes/Receita.class delete mode 100644 out/production/DesafioMaquinaDeCafe/cafes/Receitas.class create mode 100644 src/cafes/NotasEMoedas.java delete mode 100644 src/cafes/Pagamento.java create mode 100644 src/cafes/Receita.java delete mode 100644 src/cafes/Receitas.java diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..e96534f --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/out/production/DesafioMaquinaDeCafe/cafes/Acucar.class b/out/production/DesafioMaquinaDeCafe/cafes/Acucar.class index a71d500f6c825c2e3cae49a5695f2bd1b841e5bf..2deb25296b71b3472da508c4dbebd10f5da60cef 100644 GIT binary patch delta 996 zcmZ`%T~8B16g|`3(qUPkF0^RSglG({5exW*w4zn~f(k_t1V5*{3odCFXtyLh7@m2x zKf))CNTNm(UwreypP=vhAB=aVjbg-Y_TD*j&zW=YPQSElwHu#*e)tF=gT-y*1>20^ z6hp_dSQn{k;1yHZa#?KTyh>o85B(;3F~FcDlCu(@HgN`L2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MaquinaDeCafe/cafes/Bebida.class b/out/production/DesafioMaquinaDeCafe/cafes/Bebida.class index 4e63fda997e7cc50d292a0f6a68243f4b48b3f85..6f636d049519c22fd3dccc0c0edb188be8999edb 100644 GIT binary patch delta 37 tcmX@id609$EPj5UC$C{tVl3W#j`1@S04cQ&U;qFB diff --git a/out/production/DesafioMaquinaDeCafe/cafes/MaquinaDeCafe.class b/out/production/DesafioMaquinaDeCafe/cafes/MaquinaDeCafe.class index fdfba08bf63971e70de6f85af2214d7f132f7f2e..108b800f6dc5dd3e38207cc1f77579a9160fcccd 100644 GIT binary patch literal 11277 zcmb7K3w%^(l|N^mcP2L>Ofrx_DZ@L2B$Pl?LMWIfL1L3Yp+cdoQ)cF-^GFL? z+bXE7wYFj{&{m{XBT8*cF~ndW8m(Hj?!)TpZo96#>aO~8wYolNDf>U)y_3u&)BRQ2 z-_3Ww*E!#L{LeYxofqC1eTInE@^^#eBDbGBI(f;*RDPo|Xe^H#$-d>A_S|SjGfcj< zv1BZ>j>%oKbeo?vrs--@HWQ04-x@WNNi!9oAeHz@*Qu1s3U=ALKbKQUqM4&CE4f zBbfn_UbEfYY_)+blc%QBo;Y8p1v0U6(!?(8ZOTrIbXqJEswPcn>$jp-+^{Fr=(M!x zF0q7RX|xQif$rEz-};|IRrn_dUM^f;#;Gc!uhD9zvbO%Q6Omps5|1Uu9t9t3Aoj64Ak4@$ zSu-iDuca&fv`(k>^fsmnn`XChQ#O_~+D*`cs7gDNv1rVQ#|{`#!(v+Js5ReaCfJ>< zw%mxV=N1uqn6A>PjoO*!^%ZJI^xR|R>t0!EX9$PdpwruFBh$=;vCnL?l2IeGJ(lT5 zE1iLU)6g|^I#rMwy@Sa=XdH-H=?1awE}gom2OC>ic*KMmZ-(4+W~|X>rp9{tx7EDS zi0m;F^@FiwuN5&OiLnz(J|b8MZ0uyD@v_Dh^VH-ZZK17xx>l!m(l!V*=OTG~gP8%L z6c-{ z>LR_dJ{U)2iM%ZV&o^a__)S?e6-ihL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yT g=`S?+yS;v7uSe|lpZ5AM{D)R?QZ2 zSI^8<8*csB$*Na!>k1*iq@ZR*b%TW@1{5N5)hiy=XWQ=Q8#TYOJT6+cg^h3&qD8k{ ztt)gxg};iG}4h>^YG)T1rvJ}`sIMbC2#o5-h4J|O#7@Ip9HfR zk;0`Ewv5blmG95$@n?FyfF*uMZx3LtYHp-g4yJcwPC&ubA+)#VGZTiP>$xh7X^g9cbd)jZ6-y}bD@d|c8cDu#hTXD68DEg(9Mzc_&CJvvjFP16AIaUFj1BGT9?{)&SluDkXOpf?j@3EL`kux%xa?<*9eoQs@E&{dF?Qh& zhVc_?|2wt+#va{)51Q2rIEq=aR2}S literal 0 HcmV?d00001 diff --git a/out/production/DesafioMaquinaDeCafe/cafes/Pagamento.class b/out/production/DesafioMaquinaDeCafe/cafes/Pagamento.class deleted file mode 100644 index 51e9003013c6c7f07502599ab871cb32c43783c4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 264 zcmZ8b%TB{U3>@dt&=5%B54aT$><18WLFy@LkwCdSVJTZBSt*bHS5HVB_<(*C!W&f_ zu%)qQEZcMZ`T7QsVG+ZFA0bE(Vn$f(c+aZlcB?k!PFDkAmYLQJj|6{tTSPb`q!qvG zUOn@c8{H0;5Ios8ErZ;&dObF!?q0d9MY+yx#dX1*ar`6(!-we!SNXp?4}|!|j$Nf! z#w}m|eYkhFaDzzPx*$pMD>xUXCJuympP+*X9%4Z^27H_gCQ~0uy$~j+1wEv{JY6*z diff --git a/out/production/DesafioMaquinaDeCafe/cafes/Receita.class b/out/production/DesafioMaquinaDeCafe/cafes/Receita.class new file mode 100644 index 0000000000000000000000000000000000000000..3f5b68da5159dc53bedeb5fe0ae786df3578b4df GIT binary patch literal 3213 zcmaJ@SyL2O6#nio(!-=t89_i$N8xXlbUgyN3j`nwZTj zW;G@cR%xnY{8{r#VrUjcOCMjR1T zXo%`qgi3*>7vz-euw{C*9P;JQbrq^-G zG)&8v6u+2}Y2Ql8l-X-`k7jrz`jpIK9ZRrOAb#F-r%X2_4J%SY$1+8#Ja5^)>!_nT z9m^Gbq8M(#>EUIH+@PaTk!y;{{nQ|!HtA?q)VgA7&zNI4w#;#?(y@A>yfq;m4Qm9J z1wP35mfg|qx^lYT^87fGsHnm^tkVMptGVQGbi~EZSopDOF z>DYwL)M?c8PZql9>F$&hPIu?Nv z8HMhYWmryHD)C&95-NFg>;u!HenO6$JxscyTUM zOR)sBNo9hao)^@-{X;aeWq7!ibF{}v5oSrhl{SxOCPqy6v>dT{lIV8~X%9))Qv2{Q z>W^8B>XIjS3#Ni zRl!g(hk}}9IfQjq*R2YrqymE`wc^1rY%}@Wdu5@~g<+hR9du4`;jrmC`70Aebrps{ zV0o#3rzi714zsfqw`(E9e!9JS(3i&eF*zB=M_2+?gVt!8-N0oKH{JQ_*`K9 zf{2uJw1(@n>Hk^TU2{>v8urQvyT8VfUjVKm>a7lDKFYz&=Qo)7$ObcC{$S=a&sk%y zUxf1RSPjH#d;pemmBLDw$67HTtC?6UAAqIYt+1T(SS#maC5g4>0az+z3TqMSk1_uj=D?^l(Gw8{q^eU81)TJ?+#o@0Br8YBo zB9v;+;<&Os3Y9@aj4SvRi(x%;Vj~*R!e3x3Ht=WGj?LJ?-&Q9&(1)%332ftYz8xlZ zGIMs}5_aP<_TU=!;yQoLx7qQ2zyaK&+A3Fe;C}sX2?Mf5VY1p1%?icmDlj&TjP|0(x0BhiG#zR`Da1ubK#d$}dv~mHDd++OG~Y z6$SkiEkhrOK))(P{z63ji6*>4u?SwJKCcC<*XblcrPmu|em5Ae2IB|8_)#!^j8DlG MC&y>_0$-x>KjvfjIsgCw literal 0 HcmV?d00001 diff --git a/out/production/DesafioMaquinaDeCafe/cafes/Receitas.class b/out/production/DesafioMaquinaDeCafe/cafes/Receitas.class deleted file mode 100644 index 86b6d4ae68f4dc611dd06d92401696dfb122bfca..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1336 zcmZ{j-)|B@5XZku;Sf9urTntAwzX>Es=eA*nmA_YUBa3yb~J(iP^{jPtd zoIt=hb0=P@3 zIcVKP9tDByQ295?Ur0TciY7K$GKTIr@I7{wO;k94aXH<4uSL~Zu9DDTURGO|p5u*Wc;can-PL&aT6zMhMz7cG3M5un#LWLU;C~H}f6!#^qMz{yzLMj}7+eX%aM6Y5LN5&?>>ts4cyhw)8UE zQvbE3q0p8lfNTcz0NA7NKJ6TyO|oU{JA_p@og;14=g3*xb8LLoVUOrrp%75IByz}N zo#rf$5~VvJ?_QVykMV?dl!~X2(({T-CTRT>hl_$XS=Lh4HL*Xod$C z2?ZKxl80%}=``QoV8+rvJpRLgDnZtChDvzq7Rk^(;=)!eNHq#lj|Dl32dPFuc6Ecf zH>)80NDT5U7Gx_5au5shJRW2#3UWvwjXOHRQ^Fv}u^>B9kfT@-J04^w3Stw;$sHg( MrVMgI{Yv1)AIeL~9{>OV diff --git a/src/cafes/Acucar.java b/src/cafes/Acucar.java index 205be30..f53c3b7 100644 --- a/src/cafes/Acucar.java +++ b/src/cafes/Acucar.java @@ -1,7 +1,8 @@ package cafes; +import java.util.ArrayList; public enum Acucar { - Nivel0("nenhuma"),Nivel1("pouquíssima"),Nivel2("pouca"),Nivel3("normal"),Nivel4("muito"),Nivel5("bastante"); + Nivel0("nenhuma"),Nivel1("pouquíssima"),Nivel2("pouca"),Nivel3("quantidade normal de"),Nivel4("muita"),Nivel5("bastante"); private String quantidadeDeAcucar; @@ -12,4 +13,17 @@ private Acucar(String quantidade){ public String getQuantidadeDeAcucar() { return this.quantidadeDeAcucar; } + + public static ArrayList getNiveisDeAcucar(){ + ArrayList Niveis = new ArrayList(); + + Niveis.add(Nivel0); + Niveis.add(Nivel1); + Niveis.add(Nivel2); + Niveis.add(Nivel3); + Niveis.add(Nivel4); + Niveis.add(Nivel5); + + return Niveis; + } } diff --git a/src/cafes/Bebida.java b/src/cafes/Bebida.java index 356e8da..06db527 100644 --- a/src/cafes/Bebida.java +++ b/src/cafes/Bebida.java @@ -4,7 +4,7 @@ public class Bebida { private int id; private String nome; - Receitas receita; + Receita receita; private double preco; private static ArrayList menu = new ArrayList(); @@ -12,7 +12,7 @@ public Bebida(){ } - public Bebida(int id, String nome, Receitas receita, double preco) { + public Bebida(int id, String nome, Receita receita, double preco) { this.id = id; this.nome = nome; this.receita = receita; diff --git a/src/cafes/MaquinaDeCafe.java b/src/cafes/MaquinaDeCafe.java index 6c315d2..1879def 100644 --- a/src/cafes/MaquinaDeCafe.java +++ b/src/cafes/MaquinaDeCafe.java @@ -1,7 +1,8 @@ package cafes; +import java.math.BigDecimal; +import java.math.RoundingMode; import java.util.Scanner; -import java.math.*; public class MaquinaDeCafe { @@ -10,22 +11,22 @@ public static void main(String[] args) { Bebida BebidasMenu = new Bebida(); ReservatorioDeAgua reservaDeAguaAtual = new ReservatorioDeAgua(); - Receitas ReceitaDeCafe = new Receitas (true, true); + Receita ReceitaDeCafe = new Receita(true, true); ReceitaDeCafe.setQuantidadeDePoCafe(10); - Receitas ReceitaDeCafeComLeite = new Receitas (true, true); + Receita ReceitaDeCafeComLeite = new Receita(true, true); ReceitaDeCafeComLeite.setQuantidadeDePoCafe(5); ReceitaDeCafeComLeite.setQuantidadeDeLeite(10); - Receitas ReceitaDeCappuccino = new Receitas (true, true); + Receita ReceitaDeCappuccino = new Receita(true, true); ReceitaDeCappuccino.setQuantidadeDePoCafe(5); ReceitaDeCappuccino.setQuantidadeDeLeite(5); ReceitaDeCappuccino.setQuantidadeDeChocolate(5); - Receitas ReceitaDeChaDeLimao = new Receitas (true, true); + Receita ReceitaDeChaDeLimao = new Receita(true, true); ReceitaDeChaDeLimao.setQuantidadeDeLimao(10); - Receitas ReceitaDeAguaQuente = new Receitas(true, false); + Receita ReceitaDeAguaQuente = new Receita(true, false); Bebida Cafe = new Bebida(0,"Café",ReceitaDeCafe, 0.50); Bebida CafeComLeite = new Bebida(1,"Café com leite", ReceitaDeCafeComLeite, 1.00); @@ -33,33 +34,39 @@ public static void main(String[] args) { Bebida ChaDeLimao = new Bebida(3,"Chá de limão", ReceitaDeChaDeLimao, 1.00); Bebida AguaQuente = new Bebida(4, "Água Quente", ReceitaDeAguaQuente, 0.00); + Inicializacao(cafeScanner, reservaDeAguaAtual, BebidasMenu); + + } + + private static void Inicializacao(Scanner cafeScanner, ReservatorioDeAgua reservaDeAguaAtual, Bebida BebidasMenu){ + String msgReservatorioDeAgua = reservaDeAguaAtual.getQuantidadeDeAguaNoReservatorio() >= 50? "suficiente para " + (reservaDeAguaAtual.getQuantidadeDeAguaNoReservatorio() /50) + " bebidas." : "vazios."; + + System.out.println("-----Seja bem-vindo a máquina de café 2021!-----"); + System.out.println("Atenção: essa máquina não devolve troco."); + System.out.println("Para sair, digite 'sair' a qualquer momento."); + System.out.println("Reservatórios de água " + msgReservatorioDeAgua); + if(reservaDeAguaAtual.getQuantidadeDeAguaNoReservatorio() > 50){ - Inicializacao(cafeScanner, reservaDeAguaAtual.getQuantidadeDeAguaNoReservatorio(), BebidasMenu); + ProcessoDeAtendimento(cafeScanner, reservaDeAguaAtual, BebidasMenu); } else { String keyRepor = "repor"; String repor = ""; do { - repor = getScanner(cafeScanner, "Por favor, digite 'repor' para repor quantidade de água"); + repor = getScanner(cafeScanner, "Por favor, digite 'repor' para repor quantidade de água"); } while(!keyRepor.equals(repor.toLowerCase())); reservaDeAguaAtual.reporQuantidadeDeAguaNoReservatorio(); System.out.println("Reservatório de água completo!"); - Inicializacao(cafeScanner, reservaDeAguaAtual.getQuantidadeDeAguaNoReservatorio(), BebidasMenu); + ProcessoDeAtendimento(cafeScanner, reservaDeAguaAtual, BebidasMenu); } - - } - private static void Inicializacao(Scanner cafeScanner, int AtualQuantidadeDeAgua, Bebida BebidasMenu) { - - String msgReservatorioDeAgua = AtualQuantidadeDeAgua > 50? "suficiente para " + (AtualQuantidadeDeAgua /50) + " bebidas" : "vazios, favor repor"; - - System.out.println("Seja bem-vindo a máquina de café 2021!"); - System.out.println("Atenção: essa máquina não devolve troco."); - System.out.println("Reservatórios de água " + msgReservatorioDeAgua); + private static void ProcessoDeAtendimento(Scanner cafeScanner, ReservatorioDeAgua reservaDeAguaAtual, Bebida BebidasMenu) { + NotasEMoedas todasNotaseMoedas = new NotasEMoedas(); + todasNotaseMoedas.getListaDeReais(); - if(AtualQuantidadeDeAgua > 50){ + if(reservaDeAguaAtual.getQuantidadeDeAguaNoReservatorio() > 50){ for (int i = 0; i < BebidasMenu.getMenu().size(); i++) { System.out.println(BebidasMenu.getMenu().get(i).getId() + " " + BebidasMenu.getMenu().get(i).getNome() + ", preço: " + (BebidasMenu.getMenu().get(i).getPreco() == 0? "grátis" : moedaEmReais(BebidasMenu.getMenu().get(i).getPreco()))); } @@ -71,9 +78,223 @@ private static void Inicializacao(Scanner cafeScanner, int AtualQuantidadeDeAgua System.out.println("A bebida escolhida foi " + BebidasMenu.getMenu().get(Integer.parseInt(bebidaEscolhida)).getNome()); + double precoBebidaEscolhida = BebidasMenu.getMenu().get(Integer.parseInt(bebidaEscolhida)).getPreco(); + + if(precoBebidaEscolhida == 0){ + System.out.println("A bebida será de graça."); + BebidasMenu.getMenu().get(Integer.parseInt(bebidaEscolhida)).receita.Processo(Acucar.Nivel0, reservaDeAguaAtual); + + Finalizacao(cafeScanner, reservaDeAguaAtual, BebidasMenu); + } else { + System.out.println("O total é de " + moedaEmReais(BebidasMenu.getMenu().get(Integer.parseInt(bebidaEscolhida)).getPreco()) + "."); + + String metodoDePagamentoEscolhido = ""; + do { + metodoDePagamentoEscolhido = getScanner(cafeScanner, "Digite 1 para pagamento em dinheiro e 2 para pagamento em cartão de débito."); + } while(metodoDePagamento(metodoDePagamentoEscolhido) == -1); + + if(String.valueOf(metodoDePagamentoEscolhido).equals("1")){ + System.out.println("A melhor opção para pagamento em dinheiro é"); + System.out.println("Sugestão 1 " + SugestoesNotasEMoedasFormatadas(BebidasMenu.getMenu().get(Integer.parseInt(bebidaEscolhida)).getPreco(), todasNotaseMoedas, false)); + System.out.println("Sugestão 2 " + SugestoesNotasEMoedasFormatadas(BebidasMenu.getMenu().get(Integer.parseInt(bebidaEscolhida)).getPreco(), todasNotaseMoedas, true)); + + String sugestaoMoeda = ""; + do { + sugestaoMoeda = getScanner(cafeScanner, "Digite 1 ou 2 para aceitar a sugestão ou 3 para adicionar qualquer nota ou moeda. Atenção: essa máquina não devolve troco."); + } while(aceitarSugestaoMoeda(sugestaoMoeda) == -1); + + if(String.valueOf(sugestaoMoeda).equals("3")){ + System.out.println("--Favor digitar o número da nota ou moeda inserida--"); + for (int i = 0; i < todasNotaseMoedas.getListaDeReais().size(); i=i+2) { + if((i+1) == todasNotaseMoedas.getListaDeReais().size()){ + System.out.println(todasNotaseMoedas.getListaDeReais().get(i).getId() + " - " + todasNotaseMoedas.getListaDeReais().get(i).getNome()); + } else { + System.out.println(todasNotaseMoedas.getListaDeReais().get(i).getId() + " - " + todasNotaseMoedas.getListaDeReais().get(i).getNome() + " " + todasNotaseMoedas.getListaDeReais().get(i + 1).getId() + " - " + todasNotaseMoedas.getListaDeReais().get(i + 1).getNome()); + } + } + + String moedaInserida = ""; + double quantoFalta = BebidasMenu.getMenu().get(Integer.parseInt(bebidaEscolhida)).getPreco(); + do { + moedaInserida = getScanner(cafeScanner, "Favor digitar o número da nota ou moeda inserida. Faltam " + moedaEmReais(quantoFalta) + ". Atenção: essa máquina não devolve troco."); + quantoFalta = calcularMoedaInserida(moedaInserida, todasNotaseMoedas, quantoFalta); + } while(quantoFalta > 0); + + System.out.println("Pagamento concluído!"); + if(quantoFalta != 0){ + System.out.println("O valor excedente é de " + moedaEmReais(quantoFalta*-1) + " e não poderá ser devolvido."); + } + } + + } else { + String pagamentoEfetuado = ""; + do { + pagamentoEfetuado = getScanner(cafeScanner, "Digite 1 para cartão inserido"); + } while(pagamentoCartaoDeDebito(pagamentoEfetuado) == -1); + } + + System.out.println("--Favor escolher um nível de açúcar para sua bebida--"); + + for (int i = 0; i < Acucar.getNiveisDeAcucar().size() ; i++) { + System.out.println(i + " - " + Acucar.getNiveisDeAcucar().get(i).getQuantidadeDeAcucar()); + } + + String nivelDeAcucarEscolhido = ""; + do { + nivelDeAcucarEscolhido = getScanner(cafeScanner, "Digite o número do nível de açúcar escolhido."); + } while(nivelDeAcucarEncontrada(nivelDeAcucarEscolhido) == -1); + + BebidasMenu.getMenu().get(Integer.parseInt(bebidaEscolhida)).receita.Processo(Acucar.getNiveisDeAcucar().get(Integer.parseInt(nivelDeAcucarEscolhido)), reservaDeAguaAtual); + Finalizacao(cafeScanner, reservaDeAguaAtual, BebidasMenu); + } } } + public static double calcularMoedaInserida(String moedaInserida, NotasEMoedas todasNotaseMoedas, double quantoFalta){ + for (int i = 0; i < todasNotaseMoedas.getListaDeReais().size(); i++) { + if(String.valueOf(moedaInserida).equals(Integer.toString(todasNotaseMoedas.getListaDeReais().get(i).getId()))){ + return quantoFalta - todasNotaseMoedas.getListaDeReais().get(i).getValor(); + } + } + return quantoFalta; + } + + public static String SugestoesNotasEMoedasFormatadas(double Preco, NotasEMoedas NotasEMoedasReais, boolean SegundaSugestao){ + String SugestaoDeNotasEMoedas = ""; + NotasEMoedas NotasEMoedasCalculadas = CalcularSugestoes(Preco, NotasEMoedasReais, SegundaSugestao); + boolean ignorarMaiorValor = false; + + if (SegundaSugestao){ + System.out.println("-- ou --"); + ignorarMaiorValor = true; + } + + for(int i = 0; i < NotasEMoedasCalculadas.getListaDeReais().size(); i++){ + if (!String.valueOf(NotasEMoedasCalculadas.getListaDeReais().get(i).getQuantidade()).equals("0")){ + if (ignorarMaiorValor){ + ignorarMaiorValor = false; + }else { + SugestaoDeNotasEMoedas += NotasEMoedasCalculadas.getListaDeReais().get(i).getQuantidade() + " unid. de " + NotasEMoedasCalculadas.getListaDeReais().get(i).getNome() + ", "; + } + } + } + SugestaoDeNotasEMoedas = SugestaoDeNotasEMoedas.substring(0, (SugestaoDeNotasEMoedas.length() - 2)); + return SugestaoDeNotasEMoedas; + } + + private static NotasEMoedas CalcularSugestoes(double Preco, NotasEMoedas NotasEMoedasReais, boolean SegundaSugestao){ + double contagemPrecoEmNotas = 0; + double contagemPrecoEmMoedas = 0; + double contagemConsiderada; + boolean encontrouMaiorValor = false; + int quantidadeDeREAL; + double precoMoedas = Preco - Math.floor(Preco); + double precoConsiderado; + + for(int i = 0; i < NotasEMoedasReais.getListaDeReais().size(); i++){ + boolean IsMoeda = NotasEMoedasReais.getListaDeReais().get(i).isMoeda() && NotasEMoedasReais.getListaDeReais().get(i).getId() != 7; + + if(!IsMoeda) { + precoConsiderado = Preco; + contagemConsiderada = contagemPrecoEmNotas; + }else{ + precoConsiderado = precoMoedas; + contagemConsiderada = contagemPrecoEmMoedas; + } + + if(SegundaSugestao && !encontrouMaiorValor){ + quantidadeDeREAL = (int)(precoConsiderado / NotasEMoedasReais.getListaDeReais().get(i).getValor()); + if (quantidadeDeREAL >= 1){ + encontrouMaiorValor = true; + } + } else { + quantidadeDeREAL = (int) ((precoConsiderado - contagemConsiderada) / NotasEMoedasReais.getListaDeReais().get(i).getValor()); + NotasEMoedasReais.getListaDeReais().get(i).setQuantidade(quantidadeDeREAL); + + if(!IsMoeda){ + contagemPrecoEmNotas += quantidadeDeREAL * NotasEMoedasReais.getListaDeReais().get(i).getValor(); + }else { + contagemPrecoEmMoedas += quantidadeDeREAL * NotasEMoedasReais.getListaDeReais().get(i).getValor(); + } + } + + if((contagemPrecoEmNotas + contagemPrecoEmMoedas) == Preco){ + break; + } + } + return NotasEMoedasReais; + } + + private static int aceitarSugestaoMoeda(String sugestaoMoeda){ + if(String.valueOf(sugestaoMoeda).equals("1") || String.valueOf(sugestaoMoeda).equals("2")){ + System.out.println("Pagamento efetuado!"); + return 1; + } + + if(String.valueOf(sugestaoMoeda).equals("3")){ + return 3; + } + + return -1; + } + + private static int nivelDeAcucarEncontrada(String nivelDeAcucarEscolhido) { + for (int i = 0; i < Acucar.getNiveisDeAcucar().size() ; i++) { + if(nivelDeAcucarEscolhido.equals(String.valueOf(i))){ + return i; + } + } + return -1; + } + + private static void Finalizacao(Scanner cafeScanner, ReservatorioDeAgua reservaDeAguaAtual, Bebida BebidasMenu){ + System.out.println("Retire a bebida e obrigado por utilizar a máquina de café."); + + String comecar = ""; + Boolean digitouCerto = false; + do { + comecar = getScanner(cafeScanner, "Digite 'sair' para sair ou 'começar' para comprar outra bebida."); + digitouCerto = solicitarRecomeco(comecar); + } while(digitouCerto); + + Inicializacao(cafeScanner, reservaDeAguaAtual, BebidasMenu); + } + + private static boolean solicitarRecomeco(String comecar){ + String keyComecarComCidilha = "começar"; + String keyComecar = "comecar"; + + if(comecar.toLowerCase().equals(keyComecar)){ + return false; + } + + if(comecar.toLowerCase().equals(keyComecarComCidilha)){ + return false; + } + + return true; + } + + + private static int pagamentoCartaoDeDebito(String pagamentoEfetuado){ + if(String.valueOf(pagamentoEfetuado).equals("1")){ + System.out.println("Transação aprovada"); + return 1; + } + + return -1; + } + + private static int metodoDePagamento(String metodoDePagamentoEscolhido){ + if(String.valueOf(metodoDePagamentoEscolhido).equals("1")){ + return 1; + } else if (String.valueOf(metodoDePagamentoEscolhido).equals("2")){ + return 2; + } + + return -1; + } + private static int bebidaEncontrada(String bebidaEscolhida, Bebida BebidasMenu){ for(int i = 0; i < BebidasMenu.getMenu().size(); i++){ int IDdasBebidasDoMenu = BebidasMenu.getMenu().get(i).getId(); @@ -93,6 +314,10 @@ private static String moedaEmReais(double valor) { private static String getScanner(Scanner cafeScanner, String mensagem) { System.out.println(mensagem); String entry = cafeScanner.nextLine(); + if (entry.equals("sair")){ + System.out.println("Obrigado por utilizar a máquina de café 2021."); + System.exit(-1); + } return entry; } } diff --git a/src/cafes/NotasEMoedas.java b/src/cafes/NotasEMoedas.java new file mode 100644 index 0000000..759a224 --- /dev/null +++ b/src/cafes/NotasEMoedas.java @@ -0,0 +1,65 @@ +package cafes; +import java.util.ArrayList; + +public class NotasEMoedas { + private int id; + private String Nome; + private double Valor; + private boolean isMoeda; + private int Quantidade; + private static ArrayList ListaDeReais = new ArrayList(); + + public NotasEMoedas(int id, String Nome, double Valor, boolean isMoeda) { + this.id = id; + this.Nome = Nome; + this.Valor = Valor; + this.isMoeda = isMoeda; + ListaDeReais.add(this); + } + + public NotasEMoedas(){ + NotasEMoedas NotaDe200 = new NotasEMoedas(0,"Nota de R$200", 200.00,false); + NotasEMoedas NotaDe100 = new NotasEMoedas(1,"Nota de R$100", 100.00,false); + NotasEMoedas NotaDe50 = new NotasEMoedas(2,"Nota de R$50", 50.00,false); + NotasEMoedas NotaDe20 = new NotasEMoedas(3,"Nota de R$20", 20.00,false); + NotasEMoedas NotaDe10 = new NotasEMoedas(4,"Nota de R$10", 10.00,false); + NotasEMoedas NotaDe5 = new NotasEMoedas(5,"Nota de R$5", 5.00,false); + NotasEMoedas NotaDe2 = new NotasEMoedas(6,"Nota de R$2", 2.00,false); + NotasEMoedas NotaDe1 = new NotasEMoedas(8,"Nota de R$1", 1.00,false); + NotasEMoedas MoedaDe1 = new NotasEMoedas(7,"Moeda de R$1", 1.00,true); + NotasEMoedas MoedaDe50 = new NotasEMoedas(8,"Moeda de R$0,50", 0.50,true); + NotasEMoedas MoedaDe25 = new NotasEMoedas(9,"Moeda de R$0,25", 0.25,true); + NotasEMoedas MoedaDe10 = new NotasEMoedas(10,"Moeda de R$0,10", 0.10,true); + NotasEMoedas MoedaDe5= new NotasEMoedas(11,"Moeda de R$0,05", 0.05,true); + NotasEMoedas MoedaDe001= new NotasEMoedas(12,"Moeda de R$0,01", 0.01,true); + } + + public static ArrayList getListaDeReais(){ + return ListaDeReais; + } + + public double getValor() { + return Valor; + } + + public void setQuantidade(int quantidade) { + Quantidade = quantidade; + } + + public int getQuantidade() { + return Quantidade; + } + + public boolean isMoeda() { + return isMoeda; + } + + public String getNome() { + return Nome; + } + + public int getId() { + return id; + } +} + diff --git a/src/cafes/Pagamento.java b/src/cafes/Pagamento.java deleted file mode 100644 index 8683f2b..0000000 --- a/src/cafes/Pagamento.java +++ /dev/null @@ -1,4 +0,0 @@ -package cafes; - -public class Pagamento { -} diff --git a/src/cafes/Receita.java b/src/cafes/Receita.java new file mode 100644 index 0000000..6290a55 --- /dev/null +++ b/src/cafes/Receita.java @@ -0,0 +1,72 @@ +package cafes; +import java.util.ArrayList; + +public class Receita { + private int quantidadeDeAgua; + private int quantidadeDePoCafe; + private int quantidadeDeLeite; + private int quantidadeDeChocolate; + private int quantidadeDeLimao; + private boolean ferverAgua; + private boolean filtro; + + public Receita(boolean ferverAgua, boolean filtro) { + this.quantidadeDeAgua = 50; + this.ferverAgua = ferverAgua; + this.filtro = filtro; + } + + public void setQuantidadeDePoCafe(int quantidadeDePoCafe) { + this.quantidadeDePoCafe = quantidadeDePoCafe; + } + + public void setQuantidadeDeLeite(int quantidadeDeLeite) { + this.quantidadeDeLeite = quantidadeDeLeite; + } + + public void setQuantidadeDeChocolate(int quantidadeDeChocolate) { + this.quantidadeDeChocolate = quantidadeDeChocolate; + } + + public void setQuantidadeDeLimao(int quantidadeDeLimao) { + this.quantidadeDeLimao = quantidadeDeLimao; + } + + public void Processo(Acucar NivelDeAcucar, ReservatorioDeAgua AtualQuantidadeDeAgua){ + ArrayList ProcessoDaReceita = new ArrayList(); + String NivelZeroAcucar = Acucar.Nivel0.getQuantidadeDeAcucar(); + + AtualQuantidadeDeAgua.atualizarNiveisDeAgua(this.quantidadeDeAgua); + if (this.ferverAgua){ + ProcessoDaReceita.add("Fervendo água"); + } + if(this.filtro){ + ProcessoDaReceita.add("Adicionando filtro"); + } + if(this.quantidadeDePoCafe > 0){ + ProcessoDaReceita.add("Adicionando " + this.quantidadeDePoCafe + "g de pó de café"); + ProcessoDaReceita.add("Passando café"); + } + if(this.quantidadeDeLeite > 0){ + ProcessoDaReceita.add("Adicionando " + this.quantidadeDeLeite + "g de leite em pó"); + } + if(this.quantidadeDeChocolate > 0){ + ProcessoDaReceita.add("Adicionando " + this.quantidadeDeChocolate + "g de chocolate em pó"); + } + if(this.quantidadeDeLimao > 0){ + ProcessoDaReceita.add("Adicionando " + this.quantidadeDeLimao + "g de pó para chá sabor limão"); + ProcessoDaReceita.add("Passando chá"); + } + if(!NivelDeAcucar.getQuantidadeDeAcucar().equals(NivelZeroAcucar)){ + ProcessoDaReceita.add("Adicionando " + NivelDeAcucar.getQuantidadeDeAcucar() + " açúcar"); + } + + Print(ProcessoDaReceita); + } + + private void Print(ArrayList ProcessoDaReceita){ + for(int i = 0; i < ProcessoDaReceita.size(); i++){ + System.out.println(ProcessoDaReceita.get(i)); + } + } +} diff --git a/src/cafes/Receitas.java b/src/cafes/Receitas.java deleted file mode 100644 index 50b197b..0000000 --- a/src/cafes/Receitas.java +++ /dev/null @@ -1,51 +0,0 @@ -package cafes; - -public class Receitas { - private int quantidadeDeAgua; - private int quantidadeDePoCafe; - private int quantidadeDeLeite; - private int quantidadeDeChocolate; - private int quantidadeDeLimao; - private boolean ferverAgua; - private boolean filtro; - - public Receitas(boolean ferverAgua, boolean filtro) { - this.quantidadeDeAgua = 50; - this.ferverAgua = ferverAgua; - this.filtro = filtro; - } - - public int getQuantidadeDePoCafe() { - return quantidadeDePoCafe; - } - - public void setQuantidadeDePoCafe(int quantidadeDePoCafe) { - this.quantidadeDePoCafe = quantidadeDePoCafe; - } - - public int getQuantidadeDeLeite() { - return quantidadeDeLeite; - } - - public void setQuantidadeDeLeite(int quantidadeDeLeite) { - this.quantidadeDeLeite = quantidadeDeLeite; - } - - public int getQuantidadeDeChocolate() { - return quantidadeDeChocolate; - } - - public void setQuantidadeDeChocolate(int quantidadeDeChocolate) { - this.quantidadeDeChocolate = quantidadeDeChocolate; - } - - public int getQuantidadeDeLimao() { - return quantidadeDeLimao; - } - - public void setQuantidadeDeLimao(int quantidadeDeLimao) { - this.quantidadeDeLimao = quantidadeDeLimao; - } - - //metodo de processo da receita -} From 3de67d8c1305ed64e7dbb327ed80cd6ba544bbf8 Mon Sep 17 00:00:00 2001 From: Lilian Date: Mon, 1 Nov 2021 18:25:23 -0300 Subject: [PATCH 5/9] =?UTF-8?q?M=C3=A1quina=20de=20caf=C3=A9=20com=20todas?= =?UTF-8?q?=20funcionalidades=20e=20refatorado?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/.gitignore | 7 + .idea/compiler.xml | 16 + .idea/jarRepositories.xml | 20 ++ ...ackson_core_jackson_annotations_2_13_0.xml | 13 + ...erxml_jackson_core_jackson_core_2_13_0.xml | 13 + ...l_jackson_core_jackson_databind_2_13_0.xml | 13 + ...Maven__com_google_code_gson_gson_2_8_9.xml | 13 + .idea/libraries/Maven__junit_junit_4_12.xml | 13 + .../Maven__org_hamcrest_hamcrest_core_1_3.xml | 13 + .idea/misc.xml | 7 + DesafioMaquinaDeCafe.iml | 18 +- .../DesafioMaquinaDeCafe/cafes/Acucar.class | Bin 1929 -> 0 bytes .../DesafioMaquinaDeCafe/cafes/Bebida.class | Bin 1217 -> 0 bytes .../cafes/MaquinaDeCafe.class | Bin 11277 -> 0 bytes .../cafes/NotasEMoedas.class | Bin 2485 -> 0 bytes .../DesafioMaquinaDeCafe/cafes/Receita.class | Bin 3213 -> 0 bytes .../cafes/ReservatorioDeAgua.class | Bin 706 -> 0 bytes pom.xml | 37 ++ src/cafes/Acucar.java | 29 -- src/cafes/Bebida.java | 38 --- src/cafes/MaquinaDeCafe.java | 323 ------------------ src/cafes/NotasEMoedas.java | 65 ---- src/cafes/ReservatorioDeAgua.java | 17 - .../movimentocodar/maquinadecafe/Acucar.java | 31 ++ .../maquinadecafe/AguaQuente.java | 14 + .../movimentocodar/maquinadecafe/Bebida.java | 33 ++ .../movimentocodar/maquinadecafe/Cafe.java | 15 + .../maquinadecafe/CafeComLeite.java | 16 + .../maquinadecafe/CafeScanner.java | 164 +++++++++ .../maquinadecafe/Cappuccino.java | 18 + .../maquinadecafe/ChaDeLimao.java | 15 + .../movimentocodar/maquinadecafe/Cupom.java | 63 ++++ .../movimentocodar/maquinadecafe/Cupons.java | 58 ++++ .../movimentocodar/maquinadecafe/Main.java | 66 ++++ .../maquinadecafe/MaquinaDeCafe.java | 82 +++++ .../maquinadecafe/NotasEMoedas.java | 63 ++++ .../maquinadecafe/Pagamento.java | 181 ++++++++++ .../maquinadecafe}/Receita.java | 22 +- .../maquinadecafe/ReservatorioDeAgua.java | 30 ++ .../movimentocodar/maquinadecafe/teste.java | 173 ++++++++++ .../movimentocodar/maquinadecafe/Acucar.class | Bin 0 -> 2493 bytes .../maquinadecafe/AguaQuente.class | Bin 0 -> 730 bytes .../movimentocodar/maquinadecafe/Bebida.class | Bin 0 -> 918 bytes .../movimentocodar/maquinadecafe/Cafe.class | Bin 0 -> 792 bytes .../maquinadecafe/CafeComLeite.class | Bin 0 -> 871 bytes .../maquinadecafe/CafeScanner.class | Bin 0 -> 6167 bytes .../maquinadecafe/Cappuccino.class | Bin 0 -> 908 bytes .../maquinadecafe/ChaDeLimao.class | Bin 0 -> 818 bytes .../movimentocodar/maquinadecafe/Cupom.class | Bin 0 -> 3118 bytes .../movimentocodar/maquinadecafe/Cupons.class | Bin 0 -> 3220 bytes .../movimentocodar/maquinadecafe/Main.class | Bin 0 -> 3882 bytes .../maquinadecafe/MaquinaDeCafe.class | Bin 0 -> 5123 bytes .../maquinadecafe/NotasEMoedas.class | Bin 0 -> 4068 bytes .../maquinadecafe/Pagamento.class | Bin 0 -> 8697 bytes .../maquinadecafe/Receita.class | Bin 0 -> 3049 bytes .../maquinadecafe/ReservatorioDeAgua.class | Bin 0 -> 1653 bytes .../movimentocodar/maquinadecafe/teste.class | Bin 0 -> 312 bytes target/cupom.json | 14 + .../compile/default-compile/createdFiles.lst | 0 .../compile/default-compile/inputFiles.lst | 7 + 60 files changed, 1231 insertions(+), 489 deletions(-) create mode 100644 .idea/compiler.xml create mode 100644 .idea/jarRepositories.xml create mode 100644 .idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_13_0.xml create mode 100644 .idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_13_0.xml create mode 100644 .idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_13_0.xml create mode 100644 .idea/libraries/Maven__com_google_code_gson_gson_2_8_9.xml create mode 100644 .idea/libraries/Maven__junit_junit_4_12.xml create mode 100644 .idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml delete mode 100644 out/production/DesafioMaquinaDeCafe/cafes/Acucar.class delete mode 100644 out/production/DesafioMaquinaDeCafe/cafes/Bebida.class delete mode 100644 out/production/DesafioMaquinaDeCafe/cafes/MaquinaDeCafe.class delete mode 100644 out/production/DesafioMaquinaDeCafe/cafes/NotasEMoedas.class delete mode 100644 out/production/DesafioMaquinaDeCafe/cafes/Receita.class delete mode 100644 out/production/DesafioMaquinaDeCafe/cafes/ReservatorioDeAgua.class create mode 100644 pom.xml delete mode 100644 src/cafes/Acucar.java delete mode 100644 src/cafes/Bebida.java delete mode 100644 src/cafes/MaquinaDeCafe.java delete mode 100644 src/cafes/NotasEMoedas.java delete mode 100644 src/cafes/ReservatorioDeAgua.java create mode 100644 src/main/java/br/com/movimentocodar/maquinadecafe/Acucar.java create mode 100644 src/main/java/br/com/movimentocodar/maquinadecafe/AguaQuente.java create mode 100644 src/main/java/br/com/movimentocodar/maquinadecafe/Bebida.java create mode 100644 src/main/java/br/com/movimentocodar/maquinadecafe/Cafe.java create mode 100644 src/main/java/br/com/movimentocodar/maquinadecafe/CafeComLeite.java create mode 100644 src/main/java/br/com/movimentocodar/maquinadecafe/CafeScanner.java create mode 100644 src/main/java/br/com/movimentocodar/maquinadecafe/Cappuccino.java create mode 100644 src/main/java/br/com/movimentocodar/maquinadecafe/ChaDeLimao.java create mode 100644 src/main/java/br/com/movimentocodar/maquinadecafe/Cupom.java create mode 100644 src/main/java/br/com/movimentocodar/maquinadecafe/Cupons.java create mode 100644 src/main/java/br/com/movimentocodar/maquinadecafe/Main.java create mode 100644 src/main/java/br/com/movimentocodar/maquinadecafe/MaquinaDeCafe.java create mode 100644 src/main/java/br/com/movimentocodar/maquinadecafe/NotasEMoedas.java create mode 100644 src/main/java/br/com/movimentocodar/maquinadecafe/Pagamento.java rename src/{cafes => main/java/br/com/movimentocodar/maquinadecafe}/Receita.java (74%) create mode 100644 src/main/java/br/com/movimentocodar/maquinadecafe/ReservatorioDeAgua.java create mode 100644 src/main/java/br/com/movimentocodar/maquinadecafe/teste.java create mode 100644 target/classes/br/com/movimentocodar/maquinadecafe/Acucar.class create mode 100644 target/classes/br/com/movimentocodar/maquinadecafe/AguaQuente.class create mode 100644 target/classes/br/com/movimentocodar/maquinadecafe/Bebida.class create mode 100644 target/classes/br/com/movimentocodar/maquinadecafe/Cafe.class create mode 100644 target/classes/br/com/movimentocodar/maquinadecafe/CafeComLeite.class create mode 100644 target/classes/br/com/movimentocodar/maquinadecafe/CafeScanner.class create mode 100644 target/classes/br/com/movimentocodar/maquinadecafe/Cappuccino.class create mode 100644 target/classes/br/com/movimentocodar/maquinadecafe/ChaDeLimao.class create mode 100644 target/classes/br/com/movimentocodar/maquinadecafe/Cupom.class create mode 100644 target/classes/br/com/movimentocodar/maquinadecafe/Cupons.class create mode 100644 target/classes/br/com/movimentocodar/maquinadecafe/Main.class create mode 100644 target/classes/br/com/movimentocodar/maquinadecafe/MaquinaDeCafe.class create mode 100644 target/classes/br/com/movimentocodar/maquinadecafe/NotasEMoedas.class create mode 100644 target/classes/br/com/movimentocodar/maquinadecafe/Pagamento.class create mode 100644 target/classes/br/com/movimentocodar/maquinadecafe/Receita.class create mode 100644 target/classes/br/com/movimentocodar/maquinadecafe/ReservatorioDeAgua.class create mode 100644 target/classes/br/com/movimentocodar/maquinadecafe/teste.class create mode 100644 target/cupom.json create mode 100644 target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst create mode 100644 target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst diff --git a/.idea/.gitignore b/.idea/.gitignore index 26d3352..89d3959 100644 --- a/.idea/.gitignore +++ b/.idea/.gitignore @@ -1,3 +1,10 @@ # Default ignored files /shelf/ /workspace.xml +.idea +.idea/libraries +/out/ +src/main/java/br.com.movimentocodar.maquinadecafe/teste.java +target/classes/ +target/generated-sources/ +target/maven-status/ \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..6ca1f0a --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 0000000..712ab9d --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_13_0.xml b/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_13_0.xml new file mode 100644 index 0000000..1a12fe8 --- /dev/null +++ b/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_13_0.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_13_0.xml b/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_13_0.xml new file mode 100644 index 0000000..1f0132f --- /dev/null +++ b/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_13_0.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_13_0.xml b/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_13_0.xml new file mode 100644 index 0000000..ac99f62 --- /dev/null +++ b/.idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_13_0.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__com_google_code_gson_gson_2_8_9.xml b/.idea/libraries/Maven__com_google_code_gson_gson_2_8_9.xml new file mode 100644 index 0000000..d376a88 --- /dev/null +++ b/.idea/libraries/Maven__com_google_code_gson_gson_2_8_9.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__junit_junit_4_12.xml b/.idea/libraries/Maven__junit_junit_4_12.xml new file mode 100644 index 0000000..d411041 --- /dev/null +++ b/.idea/libraries/Maven__junit_junit_4_12.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml b/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml new file mode 100644 index 0000000..f58bbc1 --- /dev/null +++ b/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 15cec4b..3b67321 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,5 +1,12 @@ + + + diff --git a/DesafioMaquinaDeCafe.iml b/DesafioMaquinaDeCafe.iml index c90834f..c6b41b1 100644 --- a/DesafioMaquinaDeCafe.iml +++ b/DesafioMaquinaDeCafe.iml @@ -1,11 +1,21 @@ - - - + + + + - + + + + + + + + + + \ No newline at end of file diff --git a/out/production/DesafioMaquinaDeCafe/cafes/Acucar.class b/out/production/DesafioMaquinaDeCafe/cafes/Acucar.class deleted file mode 100644 index 2deb25296b71b3472da508c4dbebd10f5da60cef..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1929 zcmZux>vGdp5dIWjBr8hdD#Rf`TQ@+lO@ot=v=qBEA%sG4lTv}Hp|@jM31Va!Y$-GR z=u7lHI@6j$m@;LU;a?xB)7@ivY!l04t#;2|zP+6N_rJei11Mup#e@RG7JE*oxM_#B zXs4hcZXkiAg5-{S;CRalrYplLCDzdlqy{=GESfZ63`DCenl>;q5M5-^dj`ybXpKe3 z49pEg>nxf#a2yK?)HBu1%H3^C!OVkE5IRocl!^rd@8bgn3EOM=4*AOEE04s1D0;%* zFYeYKId)Lek;O+U77d)n8A3Hs*!IIFML7^&=GjKz&YfoXl2)TgDVO$!>%IBoB1kdS1@oMpC~Y&gu)NphG;m~oL>D&cr>7j3kqf> z>M(G<;%2)oo>tsWpkoQk9C$@RESIk`f6>4i)`=I5hJv|a6j3?y_cbImT%yE%$A1_$ zg-)O@v!9ZJ+^|I-_fbsws)m#XO4NAV3ZH~;fA4hMrqEz$*ra}t&?at1!!_#4AknPf zYBz`;fsCzpR`5UAw+!}wOK zK{GH@aeZeeY}TFj9Z~m4vN$HE{OCM!;aj%ws-o?(QDhnSMUx!FgNH6f*9UnhNLlW_ zFM_a5=ObnAk4cr}`%Z9sOp`~)G%}#4; zVu-Uw;ryvXoGmOpNB&Q#!!f7n6f!d%lk{U>8M0)LcV#~ORVA-6+#~4(zNbhv+>h`T zi88)K;V6E zN+ZROctzgKPh;k1hxq&%Vv;S#%`YUYO7_cyxgl9yvR9MlmSm?SyRDknC7YJ)4b8kM f+1Z!4^$Z#Aa}S0tdzzrW#p$b;q>TohPr&&fKfRJ7 diff --git a/out/production/DesafioMaquinaDeCafe/cafes/Bebida.class b/out/production/DesafioMaquinaDeCafe/cafes/Bebida.class deleted file mode 100644 index 6f636d049519c22fd3dccc0c0edb188be8999edb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1217 zcmZuvYflqV5IwhD+_o%lDjyolH%htsI;7>8} zSxGeU2l%6mXYN)gWcS0pcV=hKoH;Xp{{H+8pp1JNB#<;=SQx-1h0#Ojol|T%ezW+b zcIehag-d16_re{8WWI2aMha;Y84H836s)@Q+C45laBE(}QAl_V1yzxtVGAP|RWSVa zk*hFXJpBk1SS>Cz^%JpNQjYY1oX4oex#yt;qL8BXG@1?_yL6Q6t=`^b_S>DH?mqIQ_rXY@O&J7dlH&S-tCx^{;wvFr z!yB>}+UDeWXJpn;Sk}H3n0#|#d9Kp4#arpTVE1Cj&-aspt_c46AWee8YG;?7=|%U(i4~= z@kL~H#ckFgYOkWaq)nlk(~SzhoNhI#U(&2Wv~_HdyD*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`sIMbC2#o5-h4J|O#7@Ip9HfR zk;0`Ewv5blmG95$@n?FyfF*uMZx3LtYHp-g4yJcwPC&ubA+)#VGZTiP>$xh7X^g9cbd)jZ6-y}bD@d|c8cDu#hTXD68DEg(9Mzc_&CJvvjFP16AIaUFj1BGT9?{)&SluDkXOpf?j@3EL`kux%xa?<*9eoQs@E&{dF?Qh& zhVc_?|2wt+#va{)51Q2rIEq=aR2}S diff --git a/out/production/DesafioMaquinaDeCafe/cafes/Receita.class b/out/production/DesafioMaquinaDeCafe/cafes/Receita.class deleted file mode 100644 index 3f5b68da5159dc53bedeb5fe0ae786df3578b4df..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3213 zcmaJ@SyL2O6#nio(!-=t89_i$N8xXlbUgyN3j`nwZTj zW;G@cR%xnY{8{r#VrUjcOCMjR1T zXo%`qgi3*>7vz-euw{C*9P;JQbrq^-G zG)&8v6u+2}Y2Ql8l-X-`k7jrz`jpIK9ZRrOAb#F-r%X2_4J%SY$1+8#Ja5^)>!_nT z9m^Gbq8M(#>EUIH+@PaTk!y;{{nQ|!HtA?q)VgA7&zNI4w#;#?(y@A>yfq;m4Qm9J z1wP35mfg|qx^lYT^87fGsHnm^tkVMptGVQGbi~EZSopDOF z>DYwL)M?c8PZql9>F$&hPIu?Nv z8HMhYWmryHD)C&95-NFg>;u!HenO6$JxscyTUM zOR)sBNo9hao)^@-{X;aeWq7!ibF{}v5oSrhl{SxOCPqy6v>dT{lIV8~X%9))Qv2{Q z>W^8B>XIjS3#Ni zRl!g(hk}}9IfQjq*R2YrqymE`wc^1rY%}@Wdu5@~g<+hR9du4`;jrmC`70Aebrps{ zV0o#3rzi714zsfqw`(E9e!9JS(3i&eF*zB=M_2+?gVt!8-N0oKH{JQ_*`K9 zf{2uJw1(@n>Hk^TU2{>v8urQvyT8VfUjVKm>a7lDKFYz&=Qo)7$ObcC{$S=a&sk%y zUxf1RSPjH#d;pemmBLDw$67HTtC?6UAAqIYt+1T(SS#maC5g4>0az+z3TqMSk1_uj=D?^l(Gw8{q^eU81)TJ?+#o@0Br8YBo zB9v;+;<&Os3Y9@aj4SvRi(x%;Vj~*R!e3x3Ht=WGj?LJ?-&Q9&(1)%332ftYz8xlZ zGIMs}5_aP<_TU=!;yQoLx7qQ2zyaK&+A3Fe;C}sX2?Mf5VY1p1%?icmDlj&TjP|0(x0BhiG#zR`Da1ubK#d$}dv~mHDd++OG~Y z6$SkiEkhrOK))(P{z63ji6*>4u?SwJKCcC<*XblcrPmu|em5Ae2IB|8_)#!^j8DlG MC&y>_0$-x>KjvfjIsgCw diff --git a/out/production/DesafioMaquinaDeCafe/cafes/ReservatorioDeAgua.class b/out/production/DesafioMaquinaDeCafe/cafes/ReservatorioDeAgua.class deleted file mode 100644 index 4843d7d240fc8208bf52a2c77d1e4dcb74ea7765..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 706 zcmah`O;5r=5PeIF<)aFyAYfubyZ{Hec~D|vFeW4f;}`d(U2zGvT3QbNCNCx$6A%6X ze~G`sI7^WB8~?EXV^IpxZ_Kk+afG=-6)KK zwHfr5YYT=?V#-1UWb#rq?wtan_Ck9ypbDxVc~|5lC}%AG~5hYXd0@Ru=@5#r8s zKj0(z$i1$d2s!>0u2p?sG{@)7o5;_aTSTFV(sk9nZU3VoOQN)P_jxr=E8xfV5iz-f~mwo`|=!l2_ diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..9bd0035 --- /dev/null +++ b/pom.xml @@ -0,0 +1,37 @@ + + + 4.0.0 + + br.com.movimentocodar.maquinadecafe + DesafioMaquinaDeCafe + 1.0-SNAPSHOT + jar + + + 16 + 16 + + + + + junit + junit + 4.12 + test + + + + com.fasterxml.jackson.core + jackson-databind + 2.13.0 + + + + com.google.code.gson + gson + 2.8.9 + + + \ No newline at end of file diff --git a/src/cafes/Acucar.java b/src/cafes/Acucar.java deleted file mode 100644 index f53c3b7..0000000 --- a/src/cafes/Acucar.java +++ /dev/null @@ -1,29 +0,0 @@ -package cafes; -import java.util.ArrayList; - -public enum Acucar { - Nivel0("nenhuma"),Nivel1("pouquíssima"),Nivel2("pouca"),Nivel3("quantidade normal de"),Nivel4("muita"),Nivel5("bastante"); - - private String quantidadeDeAcucar; - - private Acucar(String quantidade){ - this.quantidadeDeAcucar = quantidade; - } - - public String getQuantidadeDeAcucar() { - return this.quantidadeDeAcucar; - } - - public static ArrayList getNiveisDeAcucar(){ - ArrayList Niveis = new ArrayList(); - - Niveis.add(Nivel0); - Niveis.add(Nivel1); - Niveis.add(Nivel2); - Niveis.add(Nivel3); - Niveis.add(Nivel4); - Niveis.add(Nivel5); - - return Niveis; - } -} diff --git a/src/cafes/Bebida.java b/src/cafes/Bebida.java deleted file mode 100644 index 06db527..0000000 --- a/src/cafes/Bebida.java +++ /dev/null @@ -1,38 +0,0 @@ -package cafes; -import java.util.ArrayList; - -public class Bebida { - private int id; - private String nome; - Receita receita; - private double preco; - private static ArrayList menu = new ArrayList(); - - public Bebida(){ - - } - - public Bebida(int id, String nome, Receita receita, double preco) { - this.id = id; - this.nome = nome; - this.receita = receita; - this.preco = preco; - Bebida.menu.add(this); - } - - public static ArrayList getMenu() { - return menu; - } - - public String getNome() { - return nome; - } - - public int getId() { - return id; - } - - public double getPreco() { - return preco; - } -} diff --git a/src/cafes/MaquinaDeCafe.java b/src/cafes/MaquinaDeCafe.java deleted file mode 100644 index 1879def..0000000 --- a/src/cafes/MaquinaDeCafe.java +++ /dev/null @@ -1,323 +0,0 @@ -package cafes; - -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.util.Scanner; - -public class MaquinaDeCafe { - - public static void main(String[] args) { - Scanner cafeScanner = new Scanner(System.in); - Bebida BebidasMenu = new Bebida(); - ReservatorioDeAgua reservaDeAguaAtual = new ReservatorioDeAgua(); - - Receita ReceitaDeCafe = new Receita(true, true); - ReceitaDeCafe.setQuantidadeDePoCafe(10); - - Receita ReceitaDeCafeComLeite = new Receita(true, true); - ReceitaDeCafeComLeite.setQuantidadeDePoCafe(5); - ReceitaDeCafeComLeite.setQuantidadeDeLeite(10); - - Receita ReceitaDeCappuccino = new Receita(true, true); - ReceitaDeCappuccino.setQuantidadeDePoCafe(5); - ReceitaDeCappuccino.setQuantidadeDeLeite(5); - ReceitaDeCappuccino.setQuantidadeDeChocolate(5); - - Receita ReceitaDeChaDeLimao = new Receita(true, true); - ReceitaDeChaDeLimao.setQuantidadeDeLimao(10); - - Receita ReceitaDeAguaQuente = new Receita(true, false); - - Bebida Cafe = new Bebida(0,"Café",ReceitaDeCafe, 0.50); - Bebida CafeComLeite = new Bebida(1,"Café com leite", ReceitaDeCafeComLeite, 1.00); - Bebida Capuccino = new Bebida(2,"Capuccino",ReceitaDeCappuccino,1.50); - Bebida ChaDeLimao = new Bebida(3,"Chá de limão", ReceitaDeChaDeLimao, 1.00); - Bebida AguaQuente = new Bebida(4, "Água Quente", ReceitaDeAguaQuente, 0.00); - - Inicializacao(cafeScanner, reservaDeAguaAtual, BebidasMenu); - - } - - private static void Inicializacao(Scanner cafeScanner, ReservatorioDeAgua reservaDeAguaAtual, Bebida BebidasMenu){ - String msgReservatorioDeAgua = reservaDeAguaAtual.getQuantidadeDeAguaNoReservatorio() >= 50? "suficiente para " + (reservaDeAguaAtual.getQuantidadeDeAguaNoReservatorio() /50) + " bebidas." : "vazios."; - - System.out.println("-----Seja bem-vindo a máquina de café 2021!-----"); - System.out.println("Atenção: essa máquina não devolve troco."); - System.out.println("Para sair, digite 'sair' a qualquer momento."); - System.out.println("Reservatórios de água " + msgReservatorioDeAgua); - - if(reservaDeAguaAtual.getQuantidadeDeAguaNoReservatorio() > 50){ - ProcessoDeAtendimento(cafeScanner, reservaDeAguaAtual, BebidasMenu); - } else { - String keyRepor = "repor"; - String repor = ""; - do - { - repor = getScanner(cafeScanner, "Por favor, digite 'repor' para repor quantidade de água"); - } while(!keyRepor.equals(repor.toLowerCase())); - - reservaDeAguaAtual.reporQuantidadeDeAguaNoReservatorio(); - System.out.println("Reservatório de água completo!"); - ProcessoDeAtendimento(cafeScanner, reservaDeAguaAtual, BebidasMenu); - } - } - - private static void ProcessoDeAtendimento(Scanner cafeScanner, ReservatorioDeAgua reservaDeAguaAtual, Bebida BebidasMenu) { - NotasEMoedas todasNotaseMoedas = new NotasEMoedas(); - todasNotaseMoedas.getListaDeReais(); - - if(reservaDeAguaAtual.getQuantidadeDeAguaNoReservatorio() > 50){ - for (int i = 0; i < BebidasMenu.getMenu().size(); i++) { - System.out.println(BebidasMenu.getMenu().get(i).getId() + " " + BebidasMenu.getMenu().get(i).getNome() + ", preço: " + (BebidasMenu.getMenu().get(i).getPreco() == 0? "grátis" : moedaEmReais(BebidasMenu.getMenu().get(i).getPreco()))); - } - - String bebidaEscolhida = ""; - do { - bebidaEscolhida = getScanner(cafeScanner, "Digite o número da bebida escolhida"); - } while(bebidaEncontrada(bebidaEscolhida, BebidasMenu) == -1); - - System.out.println("A bebida escolhida foi " + BebidasMenu.getMenu().get(Integer.parseInt(bebidaEscolhida)).getNome()); - - double precoBebidaEscolhida = BebidasMenu.getMenu().get(Integer.parseInt(bebidaEscolhida)).getPreco(); - - if(precoBebidaEscolhida == 0){ - System.out.println("A bebida será de graça."); - BebidasMenu.getMenu().get(Integer.parseInt(bebidaEscolhida)).receita.Processo(Acucar.Nivel0, reservaDeAguaAtual); - - Finalizacao(cafeScanner, reservaDeAguaAtual, BebidasMenu); - } else { - System.out.println("O total é de " + moedaEmReais(BebidasMenu.getMenu().get(Integer.parseInt(bebidaEscolhida)).getPreco()) + "."); - - String metodoDePagamentoEscolhido = ""; - do { - metodoDePagamentoEscolhido = getScanner(cafeScanner, "Digite 1 para pagamento em dinheiro e 2 para pagamento em cartão de débito."); - } while(metodoDePagamento(metodoDePagamentoEscolhido) == -1); - - if(String.valueOf(metodoDePagamentoEscolhido).equals("1")){ - System.out.println("A melhor opção para pagamento em dinheiro é"); - System.out.println("Sugestão 1 " + SugestoesNotasEMoedasFormatadas(BebidasMenu.getMenu().get(Integer.parseInt(bebidaEscolhida)).getPreco(), todasNotaseMoedas, false)); - System.out.println("Sugestão 2 " + SugestoesNotasEMoedasFormatadas(BebidasMenu.getMenu().get(Integer.parseInt(bebidaEscolhida)).getPreco(), todasNotaseMoedas, true)); - - String sugestaoMoeda = ""; - do { - sugestaoMoeda = getScanner(cafeScanner, "Digite 1 ou 2 para aceitar a sugestão ou 3 para adicionar qualquer nota ou moeda. Atenção: essa máquina não devolve troco."); - } while(aceitarSugestaoMoeda(sugestaoMoeda) == -1); - - if(String.valueOf(sugestaoMoeda).equals("3")){ - System.out.println("--Favor digitar o número da nota ou moeda inserida--"); - for (int i = 0; i < todasNotaseMoedas.getListaDeReais().size(); i=i+2) { - if((i+1) == todasNotaseMoedas.getListaDeReais().size()){ - System.out.println(todasNotaseMoedas.getListaDeReais().get(i).getId() + " - " + todasNotaseMoedas.getListaDeReais().get(i).getNome()); - } else { - System.out.println(todasNotaseMoedas.getListaDeReais().get(i).getId() + " - " + todasNotaseMoedas.getListaDeReais().get(i).getNome() + " " + todasNotaseMoedas.getListaDeReais().get(i + 1).getId() + " - " + todasNotaseMoedas.getListaDeReais().get(i + 1).getNome()); - } - } - - String moedaInserida = ""; - double quantoFalta = BebidasMenu.getMenu().get(Integer.parseInt(bebidaEscolhida)).getPreco(); - do { - moedaInserida = getScanner(cafeScanner, "Favor digitar o número da nota ou moeda inserida. Faltam " + moedaEmReais(quantoFalta) + ". Atenção: essa máquina não devolve troco."); - quantoFalta = calcularMoedaInserida(moedaInserida, todasNotaseMoedas, quantoFalta); - } while(quantoFalta > 0); - - System.out.println("Pagamento concluído!"); - if(quantoFalta != 0){ - System.out.println("O valor excedente é de " + moedaEmReais(quantoFalta*-1) + " e não poderá ser devolvido."); - } - } - - } else { - String pagamentoEfetuado = ""; - do { - pagamentoEfetuado = getScanner(cafeScanner, "Digite 1 para cartão inserido"); - } while(pagamentoCartaoDeDebito(pagamentoEfetuado) == -1); - } - - System.out.println("--Favor escolher um nível de açúcar para sua bebida--"); - - for (int i = 0; i < Acucar.getNiveisDeAcucar().size() ; i++) { - System.out.println(i + " - " + Acucar.getNiveisDeAcucar().get(i).getQuantidadeDeAcucar()); - } - - String nivelDeAcucarEscolhido = ""; - do { - nivelDeAcucarEscolhido = getScanner(cafeScanner, "Digite o número do nível de açúcar escolhido."); - } while(nivelDeAcucarEncontrada(nivelDeAcucarEscolhido) == -1); - - BebidasMenu.getMenu().get(Integer.parseInt(bebidaEscolhida)).receita.Processo(Acucar.getNiveisDeAcucar().get(Integer.parseInt(nivelDeAcucarEscolhido)), reservaDeAguaAtual); - Finalizacao(cafeScanner, reservaDeAguaAtual, BebidasMenu); - } - } - } - - public static double calcularMoedaInserida(String moedaInserida, NotasEMoedas todasNotaseMoedas, double quantoFalta){ - for (int i = 0; i < todasNotaseMoedas.getListaDeReais().size(); i++) { - if(String.valueOf(moedaInserida).equals(Integer.toString(todasNotaseMoedas.getListaDeReais().get(i).getId()))){ - return quantoFalta - todasNotaseMoedas.getListaDeReais().get(i).getValor(); - } - } - return quantoFalta; - } - - public static String SugestoesNotasEMoedasFormatadas(double Preco, NotasEMoedas NotasEMoedasReais, boolean SegundaSugestao){ - String SugestaoDeNotasEMoedas = ""; - NotasEMoedas NotasEMoedasCalculadas = CalcularSugestoes(Preco, NotasEMoedasReais, SegundaSugestao); - boolean ignorarMaiorValor = false; - - if (SegundaSugestao){ - System.out.println("-- ou --"); - ignorarMaiorValor = true; - } - - for(int i = 0; i < NotasEMoedasCalculadas.getListaDeReais().size(); i++){ - if (!String.valueOf(NotasEMoedasCalculadas.getListaDeReais().get(i).getQuantidade()).equals("0")){ - if (ignorarMaiorValor){ - ignorarMaiorValor = false; - }else { - SugestaoDeNotasEMoedas += NotasEMoedasCalculadas.getListaDeReais().get(i).getQuantidade() + " unid. de " + NotasEMoedasCalculadas.getListaDeReais().get(i).getNome() + ", "; - } - } - } - SugestaoDeNotasEMoedas = SugestaoDeNotasEMoedas.substring(0, (SugestaoDeNotasEMoedas.length() - 2)); - return SugestaoDeNotasEMoedas; - } - - private static NotasEMoedas CalcularSugestoes(double Preco, NotasEMoedas NotasEMoedasReais, boolean SegundaSugestao){ - double contagemPrecoEmNotas = 0; - double contagemPrecoEmMoedas = 0; - double contagemConsiderada; - boolean encontrouMaiorValor = false; - int quantidadeDeREAL; - double precoMoedas = Preco - Math.floor(Preco); - double precoConsiderado; - - for(int i = 0; i < NotasEMoedasReais.getListaDeReais().size(); i++){ - boolean IsMoeda = NotasEMoedasReais.getListaDeReais().get(i).isMoeda() && NotasEMoedasReais.getListaDeReais().get(i).getId() != 7; - - if(!IsMoeda) { - precoConsiderado = Preco; - contagemConsiderada = contagemPrecoEmNotas; - }else{ - precoConsiderado = precoMoedas; - contagemConsiderada = contagemPrecoEmMoedas; - } - - if(SegundaSugestao && !encontrouMaiorValor){ - quantidadeDeREAL = (int)(precoConsiderado / NotasEMoedasReais.getListaDeReais().get(i).getValor()); - if (quantidadeDeREAL >= 1){ - encontrouMaiorValor = true; - } - } else { - quantidadeDeREAL = (int) ((precoConsiderado - contagemConsiderada) / NotasEMoedasReais.getListaDeReais().get(i).getValor()); - NotasEMoedasReais.getListaDeReais().get(i).setQuantidade(quantidadeDeREAL); - - if(!IsMoeda){ - contagemPrecoEmNotas += quantidadeDeREAL * NotasEMoedasReais.getListaDeReais().get(i).getValor(); - }else { - contagemPrecoEmMoedas += quantidadeDeREAL * NotasEMoedasReais.getListaDeReais().get(i).getValor(); - } - } - - if((contagemPrecoEmNotas + contagemPrecoEmMoedas) == Preco){ - break; - } - } - return NotasEMoedasReais; - } - - private static int aceitarSugestaoMoeda(String sugestaoMoeda){ - if(String.valueOf(sugestaoMoeda).equals("1") || String.valueOf(sugestaoMoeda).equals("2")){ - System.out.println("Pagamento efetuado!"); - return 1; - } - - if(String.valueOf(sugestaoMoeda).equals("3")){ - return 3; - } - - return -1; - } - - private static int nivelDeAcucarEncontrada(String nivelDeAcucarEscolhido) { - for (int i = 0; i < Acucar.getNiveisDeAcucar().size() ; i++) { - if(nivelDeAcucarEscolhido.equals(String.valueOf(i))){ - return i; - } - } - return -1; - } - - private static void Finalizacao(Scanner cafeScanner, ReservatorioDeAgua reservaDeAguaAtual, Bebida BebidasMenu){ - System.out.println("Retire a bebida e obrigado por utilizar a máquina de café."); - - String comecar = ""; - Boolean digitouCerto = false; - do { - comecar = getScanner(cafeScanner, "Digite 'sair' para sair ou 'começar' para comprar outra bebida."); - digitouCerto = solicitarRecomeco(comecar); - } while(digitouCerto); - - Inicializacao(cafeScanner, reservaDeAguaAtual, BebidasMenu); - } - - private static boolean solicitarRecomeco(String comecar){ - String keyComecarComCidilha = "começar"; - String keyComecar = "comecar"; - - if(comecar.toLowerCase().equals(keyComecar)){ - return false; - } - - if(comecar.toLowerCase().equals(keyComecarComCidilha)){ - return false; - } - - return true; - } - - - private static int pagamentoCartaoDeDebito(String pagamentoEfetuado){ - if(String.valueOf(pagamentoEfetuado).equals("1")){ - System.out.println("Transação aprovada"); - return 1; - } - - return -1; - } - - private static int metodoDePagamento(String metodoDePagamentoEscolhido){ - if(String.valueOf(metodoDePagamentoEscolhido).equals("1")){ - return 1; - } else if (String.valueOf(metodoDePagamentoEscolhido).equals("2")){ - return 2; - } - - return -1; - } - - private static int bebidaEncontrada(String bebidaEscolhida, Bebida BebidasMenu){ - for(int i = 0; i < BebidasMenu.getMenu().size(); i++){ - int IDdasBebidasDoMenu = BebidasMenu.getMenu().get(i).getId(); - if(String.valueOf(IDdasBebidasDoMenu).equals(bebidaEscolhida)){ - return IDdasBebidasDoMenu; - } - } - - return -1; - } - - private static String moedaEmReais(double valor) { - BigDecimal b = new BigDecimal(valor); - return "R$ " + b.setScale(2, RoundingMode.HALF_EVEN); - } - - private static String getScanner(Scanner cafeScanner, String mensagem) { - System.out.println(mensagem); - String entry = cafeScanner.nextLine(); - if (entry.equals("sair")){ - System.out.println("Obrigado por utilizar a máquina de café 2021."); - System.exit(-1); - } - return entry; - } -} diff --git a/src/cafes/NotasEMoedas.java b/src/cafes/NotasEMoedas.java deleted file mode 100644 index 759a224..0000000 --- a/src/cafes/NotasEMoedas.java +++ /dev/null @@ -1,65 +0,0 @@ -package cafes; -import java.util.ArrayList; - -public class NotasEMoedas { - private int id; - private String Nome; - private double Valor; - private boolean isMoeda; - private int Quantidade; - private static ArrayList ListaDeReais = new ArrayList(); - - public NotasEMoedas(int id, String Nome, double Valor, boolean isMoeda) { - this.id = id; - this.Nome = Nome; - this.Valor = Valor; - this.isMoeda = isMoeda; - ListaDeReais.add(this); - } - - public NotasEMoedas(){ - NotasEMoedas NotaDe200 = new NotasEMoedas(0,"Nota de R$200", 200.00,false); - NotasEMoedas NotaDe100 = new NotasEMoedas(1,"Nota de R$100", 100.00,false); - NotasEMoedas NotaDe50 = new NotasEMoedas(2,"Nota de R$50", 50.00,false); - NotasEMoedas NotaDe20 = new NotasEMoedas(3,"Nota de R$20", 20.00,false); - NotasEMoedas NotaDe10 = new NotasEMoedas(4,"Nota de R$10", 10.00,false); - NotasEMoedas NotaDe5 = new NotasEMoedas(5,"Nota de R$5", 5.00,false); - NotasEMoedas NotaDe2 = new NotasEMoedas(6,"Nota de R$2", 2.00,false); - NotasEMoedas NotaDe1 = new NotasEMoedas(8,"Nota de R$1", 1.00,false); - NotasEMoedas MoedaDe1 = new NotasEMoedas(7,"Moeda de R$1", 1.00,true); - NotasEMoedas MoedaDe50 = new NotasEMoedas(8,"Moeda de R$0,50", 0.50,true); - NotasEMoedas MoedaDe25 = new NotasEMoedas(9,"Moeda de R$0,25", 0.25,true); - NotasEMoedas MoedaDe10 = new NotasEMoedas(10,"Moeda de R$0,10", 0.10,true); - NotasEMoedas MoedaDe5= new NotasEMoedas(11,"Moeda de R$0,05", 0.05,true); - NotasEMoedas MoedaDe001= new NotasEMoedas(12,"Moeda de R$0,01", 0.01,true); - } - - public static ArrayList getListaDeReais(){ - return ListaDeReais; - } - - public double getValor() { - return Valor; - } - - public void setQuantidade(int quantidade) { - Quantidade = quantidade; - } - - public int getQuantidade() { - return Quantidade; - } - - public boolean isMoeda() { - return isMoeda; - } - - public String getNome() { - return Nome; - } - - public int getId() { - return id; - } -} - diff --git a/src/cafes/ReservatorioDeAgua.java b/src/cafes/ReservatorioDeAgua.java deleted file mode 100644 index 350d26d..0000000 --- a/src/cafes/ReservatorioDeAgua.java +++ /dev/null @@ -1,17 +0,0 @@ -package cafes; - -public class ReservatorioDeAgua { - private int QuantidadeDeAguaNoReservatorio = 1000; - - public int getQuantidadeDeAguaNoReservatorio() { - return QuantidadeDeAguaNoReservatorio; - } - - public void atualizarNiveisDeAgua(int quantidadeDeAguaUtilizada) { - QuantidadeDeAguaNoReservatorio = QuantidadeDeAguaNoReservatorio - quantidadeDeAguaUtilizada; - } - - public void reporQuantidadeDeAguaNoReservatorio() { - QuantidadeDeAguaNoReservatorio = 1000; - } -} diff --git a/src/main/java/br/com/movimentocodar/maquinadecafe/Acucar.java b/src/main/java/br/com/movimentocodar/maquinadecafe/Acucar.java new file mode 100644 index 0000000..7d0d61e --- /dev/null +++ b/src/main/java/br/com/movimentocodar/maquinadecafe/Acucar.java @@ -0,0 +1,31 @@ +package br.com.movimentocodar.maquinadecafe; + +public enum Acucar { + NIVEL_0(0,"nenhuma"), + NIVEL_1(1,"pouquíssima"), + NIVEL_2(2,"pouca"), + NIVEL_3(3,"quantidade normal de"), + NIVEL_4(4,"muita"), + NIVEL_5(5,"bastante"); + + private int id; + private String descricao; + + private Acucar(int id, String descricao){ + this.descricao = descricao; + this.id = id; + } + + public String getDescricao() { + return descricao; + } + + public int getId() { + return id; + } + + public void imprimirNiveisDeAcucar(){ + System.out.println(this.id + " - " + this.descricao); + } + +} diff --git a/src/main/java/br/com/movimentocodar/maquinadecafe/AguaQuente.java b/src/main/java/br/com/movimentocodar/maquinadecafe/AguaQuente.java new file mode 100644 index 0000000..aed4cfc --- /dev/null +++ b/src/main/java/br/com/movimentocodar/maquinadecafe/AguaQuente.java @@ -0,0 +1,14 @@ +package br.com.movimentocodar.maquinadecafe; + +import java.math.BigDecimal; + +public class AguaQuente extends Bebida { + Receita Receita = new Receita(true, false); + BigDecimal Preco = BigDecimal.ZERO; + + public AguaQuente() { + super(4, "Água quente"); + this.preco = Preco; + this.receita = Receita; + } +} diff --git a/src/main/java/br/com/movimentocodar/maquinadecafe/Bebida.java b/src/main/java/br/com/movimentocodar/maquinadecafe/Bebida.java new file mode 100644 index 0000000..30766e7 --- /dev/null +++ b/src/main/java/br/com/movimentocodar/maquinadecafe/Bebida.java @@ -0,0 +1,33 @@ +package br.com.movimentocodar.maquinadecafe; + +import java.math.BigDecimal; + +public class Bebida { + private int id; + private String nome; + Receita receita; + protected BigDecimal preco; + + public Bebida(int id, String nome) { + this.id = id; + this.nome = nome; + this.preco = preco; + } + + public Bebida() { + } + + @Override + public String toString() { + return nome; + } + + public int getId() { + return id; + } + + public BigDecimal getPreco() { + return preco; + } + +} diff --git a/src/main/java/br/com/movimentocodar/maquinadecafe/Cafe.java b/src/main/java/br/com/movimentocodar/maquinadecafe/Cafe.java new file mode 100644 index 0000000..537fe91 --- /dev/null +++ b/src/main/java/br/com/movimentocodar/maquinadecafe/Cafe.java @@ -0,0 +1,15 @@ +package br.com.movimentocodar.maquinadecafe; + +import java.math.BigDecimal; + +public class Cafe extends Bebida{ + Receita Receita = new Receita(true, true); + BigDecimal Preco = new BigDecimal("0.50"); + + public Cafe() { + super(0, "Café"); + Receita.setQuantidadeDePoCafe(10); + this.preco = Preco; + this.receita = Receita; + } +} diff --git a/src/main/java/br/com/movimentocodar/maquinadecafe/CafeComLeite.java b/src/main/java/br/com/movimentocodar/maquinadecafe/CafeComLeite.java new file mode 100644 index 0000000..b6f7709 --- /dev/null +++ b/src/main/java/br/com/movimentocodar/maquinadecafe/CafeComLeite.java @@ -0,0 +1,16 @@ +package br.com.movimentocodar.maquinadecafe; + +import java.math.BigDecimal; + +public class CafeComLeite extends Bebida { + Receita Receita = new Receita(true, true); + BigDecimal Preco = new BigDecimal("1.00"); + + public CafeComLeite() { + super(1, "Café com leite"); + Receita.setQuantidadeDePoCafe(5); + Receita.setQuantidadeDeLeite(10); + this.preco = Preco; + this.receita = Receita; + } +} diff --git a/src/main/java/br/com/movimentocodar/maquinadecafe/CafeScanner.java b/src/main/java/br/com/movimentocodar/maquinadecafe/CafeScanner.java new file mode 100644 index 0000000..dd9e370 --- /dev/null +++ b/src/main/java/br/com/movimentocodar/maquinadecafe/CafeScanner.java @@ -0,0 +1,164 @@ +package br.com.movimentocodar.maquinadecafe; + +import java.math.BigDecimal; +import java.util.Scanner; + +public class CafeScanner { + Scanner Scanner = new Scanner(System.in); + + private String mensagem; + private String respostaEsperada; + + public CafeScanner(String mensagem, String respostaEsperada) { + this.mensagem = mensagem; + this.respostaEsperada = respostaEsperada; + } + + public CafeScanner(String mensagem) { + this.mensagem = mensagem; + } + + public void pedirConfirmacaoUsuario(){ + String entry = ""; + do + { + System.out.println(this.mensagem); + entry = Scanner.nextLine(); + checarSair(entry); + } while(!entry.equals(this.respostaEsperada.toLowerCase())); + } + + public Bebida pedirSelecaoBebidaDoUsuario(MaquinaDeCafe MaquinaDeCafe){ + String entry = ""; + do + { + System.out.println(this.mensagem); + entry = Scanner.nextLine(); + checarSair(entry); + } while(!bebidaEncontrada(entry, MaquinaDeCafe)); + + Bebida BebidaEscolhida = MaquinaDeCafe.getBebida(Integer.parseInt(entry)); + System.out.println("A bebida escolhida foi " + BebidaEscolhida.toString()); + + return BebidaEscolhida; + } + + public BigDecimal pedirSelecaoReaisAoUsuario(BigDecimal preco){ + String entry = ""; + BigDecimal valorInserido = BigDecimal.ZERO; + BigDecimal valorAPagar = preco; + BigDecimal valorPago = BigDecimal.ZERO; + do + { + valorAPagar = preco.subtract(valorPago); + System.out.println(this.mensagem); + System.out.println("Faltam " + Pagamento.moedaEmReais(valorAPagar)); + entry = Scanner.nextLine(); + checarSair(entry); + valorInserido = calcularValorInserido(entry); + valorPago = valorPago.add(valorInserido); + } while(valorPago.compareTo(preco) < 0); + + + return valorPago.subtract(preco); + } + + private BigDecimal calcularValorInserido(String entry){ + + NotasEMoedas Reais[] = NotasEMoedas.values(); + for (NotasEMoedas real: Reais) { + if(entry.equals(Integer.toString(real.getId()))){ + return real.getValor(); + } + } + + return BigDecimal.ZERO; + } + + public Acucar pedirSelecaoAcucarDoUsuario(){ + Acucar AcucarEscolhida = Acucar.NIVEL_0; + String entry = ""; + do + { + System.out.println(this.mensagem); + entry = Scanner.nextLine(); + checarSair(entry); + } while(!acucarEncontrada(entry)); + + Acucar NiveisAcucar[] = Acucar.values(); + for (Acucar nivel: NiveisAcucar) { + if (entry.equals(Integer.toString(nivel.getId()))){ + AcucarEscolhida = nivel; + } + } + + return AcucarEscolhida; + } + + private boolean acucarEncontrada(String entry){ + Acucar NiveisAcucar[] = Acucar.values(); + for (Acucar nivel: NiveisAcucar) { + if (entry.equals(Integer.toString(nivel.getId()))){ + return true; + } + } + + return false; + } + + public int pedirMetodoDePagamentoAoUsuario(){ + String entry = ""; + do + { + System.out.println(this.mensagem); + entry = Scanner.nextLine(); + checarSair(entry); + } while(!metodoEncontrado(entry)); + + return Integer.parseInt(entry); + } + + private boolean metodoEncontrado(String entry){ + if (entry.equals("1") || entry.equals("2") || entry.equals("3")){ + return true; + } + + return false; + } + + private boolean bebidaEncontrada(String bebidaEscolhida, MaquinaDeCafe MaquinaDeCafe){ + try{ + MaquinaDeCafe.getBebida(Integer.parseInt(bebidaEscolhida)); + } catch (Exception ex) { + return false; + } + + return true; + } + + private void checarSair(String entry){ + if (entry.equals("sair")){ + System.out.println("Obrigado por utilizar a máquina de café 2021."); + System.exit(-1); + } + } + + public Cupom pedirCodigoCupom(Cupons cupons) { + String entry = ""; + do + { + System.out.println(this.mensagem); + entry = Scanner.nextLine(); + checarSair(entry); + } while(!CupomEncontrado(cupons, entry)); + + return (Cupom) cupons.encontrarCupom(entry); + } + + private boolean CupomEncontrado(Cupons cupons, String entry){ + if(cupons.encontrarCupom(entry) != null){ + return true; + } + return false; + } +} diff --git a/src/main/java/br/com/movimentocodar/maquinadecafe/Cappuccino.java b/src/main/java/br/com/movimentocodar/maquinadecafe/Cappuccino.java new file mode 100644 index 0000000..41a16aa --- /dev/null +++ b/src/main/java/br/com/movimentocodar/maquinadecafe/Cappuccino.java @@ -0,0 +1,18 @@ +package br.com.movimentocodar.maquinadecafe; + +import java.math.BigDecimal; + +public class Cappuccino extends Bebida { + Receita Receita = new Receita(true, true); + BigDecimal Preco = new BigDecimal("1.50"); + + + public Cappuccino() { + super(2, "Cappuccino"); + Receita.setQuantidadeDePoCafe(5); + Receita.setQuantidadeDeLeite(5); + Receita.setQuantidadeDeChocolate(5); + this.preco = Preco; + this.receita = Receita; + } +} diff --git a/src/main/java/br/com/movimentocodar/maquinadecafe/ChaDeLimao.java b/src/main/java/br/com/movimentocodar/maquinadecafe/ChaDeLimao.java new file mode 100644 index 0000000..6614c99 --- /dev/null +++ b/src/main/java/br/com/movimentocodar/maquinadecafe/ChaDeLimao.java @@ -0,0 +1,15 @@ +package br.com.movimentocodar.maquinadecafe; + +import java.math.BigDecimal; + +public class ChaDeLimao extends Bebida { + Receita Receita = new Receita(true, true); + BigDecimal Preco = new BigDecimal("1.00"); + + public ChaDeLimao() { + super(3, "Chá de limão"); + Receita.setQuantidadeDeLimao(10); + this.preco = Preco; + this.receita = Receita; + } +} diff --git a/src/main/java/br/com/movimentocodar/maquinadecafe/Cupom.java b/src/main/java/br/com/movimentocodar/maquinadecafe/Cupom.java new file mode 100644 index 0000000..0416e33 --- /dev/null +++ b/src/main/java/br/com/movimentocodar/maquinadecafe/Cupom.java @@ -0,0 +1,63 @@ +package br.com.movimentocodar.maquinadecafe; + +import java.math.BigDecimal; +import java.sql.Timestamp; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; + +public class Cupom { + BigDecimal valor; + LocalDateTime validade; + Timestamp agora; + Boolean ativo; + String codigo; + + public Cupom(BigDecimal valor, Timestamp agora, Boolean ativo) { + this.valor = valor; + this.ativo = ativo; + this.agora = agora; + gerarCodigo(); + calcularValidade(); + } + + private void gerarCodigo(){ + LocalDateTime dataString = this.agora.toLocalDateTime(); + long cupomNum = this.agora.getTime() * 3; + this.codigo = dataString.getMonth().toString().substring(0, 3) + Integer.toString(dataString.getYear()).substring(2, 4) + "-" + Long.toString(cupomNum); + } + + public void calcularValidade() { + LocalDateTime dataValidade = this.agora.toLocalDateTime(); + this.validade = dataValidade.plusMonths(3); + } + + public void inativarCupom(){ + this.ativo = false; + } + + public String getCodigo() { + return this.codigo; + } + + public BigDecimal getValor() { + return this.valor; + } + + public String getValidade() { + DateTimeFormatter formatoData = DateTimeFormatter.ofPattern("dd/MM/yyyy"); + return this.validade.format(formatoData); + } + + public boolean checaValidade(){ + if (LocalDate.now().compareTo(this.validade.toLocalDate()) < 1){ + return true; + } + return false; + } + + public Boolean getAtivo() { + return this.ativo; + } + +} diff --git a/src/main/java/br/com/movimentocodar/maquinadecafe/Cupons.java b/src/main/java/br/com/movimentocodar/maquinadecafe/Cupons.java new file mode 100644 index 0000000..8bacc11 --- /dev/null +++ b/src/main/java/br/com/movimentocodar/maquinadecafe/Cupons.java @@ -0,0 +1,58 @@ +package br.com.movimentocodar.maquinadecafe; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SequenceWriter; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; + +public class Cupons { + private Map mapCupons = new HashMap<>(); + String codigo; + Cupom cupom; + + public Cupons(){} + + public void addCupom(String codigo, Cupom cupom){ + this.mapCupons.put(codigo, cupom); + } + + public Cupom encontrarCupom(String codigo){ + return (Cupom)this.mapCupons.get(codigo); + } + + @Override + public String toString(){ + return "Esse cupom é " + codigo + ", no valor de: " + Pagamento.moedaEmReais(cupom.getValor()) + ", válido até: " + cupom.getValidade() + "." ; + } + + /*public void lerJSON() throws IOException { + + JsonElement root = new JsonParser().parse(new FileReader("target/cupom.json")); + JsonObject object = root.getAsJsonObject(); + Gson gson = new Gson(); + for (Map.Entry entry : object.entrySet()) { + Cupom cupom = gson.fromJson(entry.getValue(), this); + System.out.println(cupom); + } + + }*/ + + public void gravarJSON() throws IOException { + //append:true para ir adicionando itens em sequencia sem resetar arquivo + File file = new File("target/cupom.json"); + FileWriter fileWriter = new FileWriter(file, false); + ObjectMapper mapper = new ObjectMapper(); + try { + SequenceWriter seqWriter = mapper.writerWithDefaultPrettyPrinter().writeValuesAsArray(fileWriter); + seqWriter.write(mapCupons); + + seqWriter.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/src/main/java/br/com/movimentocodar/maquinadecafe/Main.java b/src/main/java/br/com/movimentocodar/maquinadecafe/Main.java new file mode 100644 index 0000000..6a4cff9 --- /dev/null +++ b/src/main/java/br/com/movimentocodar/maquinadecafe/Main.java @@ -0,0 +1,66 @@ +package br.com.movimentocodar.maquinadecafe; + +import com.fasterxml.jackson.core.JsonParseException; + +import java.io.IOException; + +/** + * Máquina de café que vende e processa diversas bebidas como + * café, café com leite, cappuccino, chá de limão e água quente. + * Aceita dinheiro, cartão e cupom como forma de pagamento. + * + * @author Lilian Ferreira + * @version 1.0 + * @since 2021-09-06 + * @link https://github.com/lilianjaf/iniciante-java-oo-2021 + */ + +public class Main { + public static void main(String[] args) throws JsonParseException, IOException { + ReservatorioDeAgua ReservatorioDeAgua = new ReservatorioDeAgua(); + Cupons cupons = new Cupons(); + inicializarMaquina(ReservatorioDeAgua, cupons); + } + + static void inicializarMaquina(ReservatorioDeAgua ReservatorioDeAgua, Cupons cupons) throws JsonParseException, IOException { + MaquinaDeCafe MaquinaDeCafe = new MaquinaDeCafe(ReservatorioDeAgua); + + if (MaquinaDeCafe.ReservatorioDeAgua.reservatorioDeAguaVazio()) { + CafeScanner ReporAgua = new CafeScanner("Por favor, digite 'repor' para repor quantidade de água", "repor"); + ReporAgua.pedirConfirmacaoUsuario(); + MaquinaDeCafe.ReservatorioDeAgua.completarReservatorioDeAgua(); + } + + MaquinaDeCafe.Menu(); + Bebida BebidaEscolhida = MaquinaDeCafe.selecionarBebida(); + Pagamento Pagamento = new Pagamento(BebidaEscolhida.getPreco()); + + if(Pagamento.Cortesia()){ + System.out.println("A bebida será de graça."); + + MaquinaDeCafe.liberarBebida(); + }else{ + System.out.println("O total é de " + Pagamento.moedaEmReais() + "."); + + Boolean sucesso; + do { + CafeScanner selecionarMetodoDePagamento = new CafeScanner("Digite 1 para pagamento em dinheiro, 2 para pagamento em cartão de débito e 3 para utilizar cupom."); + int MetodoDePagamento = selecionarMetodoDePagamento.pedirMetodoDePagamentoAoUsuario(); + sucesso = Pagamento.executarCobranca(MetodoDePagamento, cupons); + }while(!sucesso); + + MaquinaDeCafe.determinarNivelDeAcucar(); + MaquinaDeCafe.liberarBebida(); + } + + finalizacao(ReservatorioDeAgua, cupons); + } + + private static void finalizacao(ReservatorioDeAgua ReservatorioDeAgua, Cupons cupons) throws JsonParseException, IOException{ + System.out.println("Retire a bebida e obrigado por utilizar a máquina de café."); + CafeScanner finalizar = new CafeScanner("Digite 'sair' para sair ou 'iniciar' para comprar outra bebida.", "iniciar"); + finalizar.pedirConfirmacaoUsuario(); + inicializarMaquina(ReservatorioDeAgua, cupons); + } + +} diff --git a/src/main/java/br/com/movimentocodar/maquinadecafe/MaquinaDeCafe.java b/src/main/java/br/com/movimentocodar/maquinadecafe/MaquinaDeCafe.java new file mode 100644 index 0000000..7810d1f --- /dev/null +++ b/src/main/java/br/com/movimentocodar/maquinadecafe/MaquinaDeCafe.java @@ -0,0 +1,82 @@ +package br.com.movimentocodar.maquinadecafe; + +import java.math.BigDecimal; +import java.util.ArrayList; + +public class MaquinaDeCafe { + ReservatorioDeAgua ReservatorioDeAgua; + private ArrayList menu = new ArrayList(); + Acucar NivelAcucarEscolhido; + Bebida BebidaEscolhida; + + public MaquinaDeCafe(ReservatorioDeAgua ReservatorioDeAgua) { + this.ReservatorioDeAgua = ReservatorioDeAgua; + + Bebida Cafe = new Cafe(); + Bebida CafeComLeite = new CafeComLeite(); + Bebida Cappuccino = new Cappuccino(); + Bebida ChaDeLimao = new ChaDeLimao(); + Bebida AguaQuente = new AguaQuente(); + menu.add(Cafe); + menu.add(CafeComLeite); + menu.add(Cappuccino); + menu.add(ChaDeLimao); + menu.add(AguaQuente); + + BoasVindas(); + } + + public void BoasVindas(){ + System.out.println("-----Seja bem-vindo a máquina de café 2021!-----"); + System.out.println("Atenção: essa máquina não devolve troco, apenas cupom."); + System.out.println("Para sair, digite 'sair' a qualquer momento."); + } + + public Bebida getBebida(int id){ + Bebida bebida = new Bebida(); + try{ + bebida = menu.get(id); + } catch (ArrayIndexOutOfBoundsException ex){ + throw ex; + } + return bebida; + } + + public void Menu(){ + for (Bebida bebida : menu) { + System.out.println(bebida.getId() + " - " + bebida.toString() + " - " + (bebida.getPreco().compareTo(BigDecimal.ZERO) == 0? "grátis" : Pagamento.moedaEmReais(bebida.getPreco()))); + } + } + + public void liberarBebida(){ + this.ReservatorioDeAgua.liberarAguaParaUmaBebida(); + + if (NivelAcucarEscolhido == null){ + NivelAcucarEscolhido = Acucar.NIVEL_0; + } + + this.BebidaEscolhida.receita.preparar(NivelAcucarEscolhido); + } + + public Bebida selecionarBebida(){ + CafeScanner selecionarBebida = new CafeScanner("Digite o número da bebida escolhida"); + this.BebidaEscolhida = selecionarBebida.pedirSelecaoBebidaDoUsuario(this); + + return this.BebidaEscolhida; + } + + public void determinarNivelDeAcucar(){ + System.out.println("--Favor escolher um nível de açúcar para sua bebida--"); + Acucar NiveisDeAcucar[] = Acucar.values(); + for (Acucar nivel : NiveisDeAcucar) { + nivel.imprimirNiveisDeAcucar(); + } + CafeScanner nivelDeAcucar = new CafeScanner("Digite o número do nível de açúcar escolhido."); + this.NivelAcucarEscolhido = nivelDeAcucar.pedirSelecaoAcucarDoUsuario(); + } + + + + + +} diff --git a/src/main/java/br/com/movimentocodar/maquinadecafe/NotasEMoedas.java b/src/main/java/br/com/movimentocodar/maquinadecafe/NotasEMoedas.java new file mode 100644 index 0000000..8a1d2f0 --- /dev/null +++ b/src/main/java/br/com/movimentocodar/maquinadecafe/NotasEMoedas.java @@ -0,0 +1,63 @@ +package br.com.movimentocodar.maquinadecafe; + +import java.math.BigDecimal; + +public enum NotasEMoedas { + NOTA_DE_200(0,"Nota de R$200", BigDecimal.valueOf(200.00), false, 0), + NOTA_DE_100(1,"Nota de R$100", BigDecimal.valueOf(100.00),false, 0), + NOTA_DE_50(2,"Nota de R$50", BigDecimal.valueOf(50.00),false,0), + NOTA_DE_20(3,"Nota de R$20", BigDecimal.valueOf(20.00),false,0), + NOTA_DE_10(4,"Nota de R$10", BigDecimal.valueOf(10.00),false,0), + NOTA_DE_5(5,"Nota de R$5", BigDecimal.valueOf(5.00),false,0), + NOTA_DE_2(6,"Nota de R$2", BigDecimal.valueOf(2.00),false,0), + NOTA_DE_1(7,"Nota de R$1", BigDecimal.valueOf(1.00),false,0), + MOEDA_DE_1(8,"Moeda de R$1", BigDecimal.valueOf(1.00),true,0), + MOEDA_DE_050(9,"Moeda de R$0,50", BigDecimal.valueOf(0.50),true,0), + MOEDA_DE_025(10,"Moeda de R$0,25", BigDecimal.valueOf(0.25),true,0), + MOEDA_DE_010(11,"Moeda de R$0,10", BigDecimal.valueOf(0.10),true,0), + MOEDA_DE_005(12,"Moeda de R$0,05", BigDecimal.valueOf(0.05),true,0), + MOEDA_DE_001(13,"Moeda de R$0,01", BigDecimal.valueOf(0.01),true,0); + + int quantidade; + boolean moeda; + int id; + String nome; + BigDecimal valor; + + NotasEMoedas(int id, String nome, BigDecimal valor, boolean moeda, int quantidade) { + this.id = id; + this.nome = nome; + this.valor = valor; + this.moeda = moeda; + this.quantidade = quantidade; + } + + public void setQuantidade(int quantidade) { + this.quantidade = quantidade; + } + + public int getQuantidade() { + return quantidade; + } + + public boolean isMoeda() { + return moeda; + } + + public int getId() { + return id; + } + + @Override + public String toString() { + return nome; + } + + public BigDecimal getValor() { + return valor; + } + + public void imprimir(){ + System.out.println(this.id + " - " + this.nome); + } +} diff --git a/src/main/java/br/com/movimentocodar/maquinadecafe/Pagamento.java b/src/main/java/br/com/movimentocodar/maquinadecafe/Pagamento.java new file mode 100644 index 0000000..b5f0d26 --- /dev/null +++ b/src/main/java/br/com/movimentocodar/maquinadecafe/Pagamento.java @@ -0,0 +1,181 @@ +package br.com.movimentocodar.maquinadecafe; + +import com.fasterxml.jackson.core.JsonParseException; + +import java.io.IOException; +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.sql.Timestamp; + +public class Pagamento { + private BigDecimal valor; + private boolean encontrouMaiorValor = false; + private int metodoDePagamento; + + public Pagamento(BigDecimal valor){ + this.valor = valor; + } + + public boolean Cortesia(){ + if (this.valor.compareTo(BigDecimal.ZERO) == 0){ + return true; + } + + return false; + } + + public String moedaEmReais() { + return "R$ " + this.valor.setScale(2, RoundingMode.HALF_EVEN); + } + + public static String moedaEmReais(BigDecimal valor) { + return "R$ " + valor.setScale(2, RoundingMode.HALF_EVEN); + } + + public boolean executarCobranca(int MetodoDePagamento, Cupons cupons) throws JsonParseException, IOException { + this.metodoDePagamento = MetodoDePagamento; + // 1: Pagamento em dinheiro + // 2: Pagamento em cartão de débito + // 3: Utilizar voucher + + if(this.metodoDePagamento == 1) { + imprimirSugestoesDePagamentoEmDinheiro(); + + CafeScanner selecionarSugestaoDePagamentoComDinheiro = new CafeScanner("Digite 1 ou 2 para aceitar a sugestão referente ou 3 para escolher qualquer nota ou moeda. Atenção: caso o valor exceda o valor da compra será gerado um cupom válido por 3 meses."); + int sugestaoDePagamentoComDinheiro = selecionarSugestaoDePagamentoComDinheiro.pedirMetodoDePagamentoAoUsuario(); + + if(sugestaoDePagamentoComDinheiro == 3){ + NotasEMoedas Reais[] = NotasEMoedas.values(); + for (NotasEMoedas real: Reais) { + real.imprimir(); + } + + CafeScanner selecionarReais = new CafeScanner("Favor digitar o número da nota ou moeda inserida. Atenção: essa máquina não devolve troco, apenas cupom válido por 3 meses."); + BigDecimal troco = selecionarReais.pedirSelecaoReaisAoUsuario(this.valor); + + if(troco.compareTo(BigDecimal.ZERO) > 0){ + //cupons.lerJSON(); + gerarCupom(troco, cupons); + cupons.gravarJSON(); + } + + return true; + + } else { + System.out.println("Pagamento aceito!"); + return true; + } + }else if(MetodoDePagamento == 2){ + CafeScanner confirmarPagamentoCartaoDeDebito = new CafeScanner("Digite 1 para cartão inserido", "1"); + confirmarPagamentoCartaoDeDebito.pedirConfirmacaoUsuario(); + System.out.println("Transação aprovada"); + return true; + }else if(MetodoDePagamento == 3) { + //cupons.lerJSON(); + CafeScanner procurarCupom = new CafeScanner("Favor digitar o código do cupom."); + Cupom cupom = procurarCupom.pedirCodigoCupom(cupons); + if(cupom.getAtivo()) { + if (cupom.checaValidade()) { + cupom.inativarCupom(); + BigDecimal troco = this.valor.subtract(cupom.getValor()); + if (troco.compareTo(BigDecimal.ZERO) < 0) { + troco = cupom.getValor().subtract(this.valor); + gerarCupom(troco, cupons); + cupons.gravarJSON(); + return true; + } else if (troco.compareTo(BigDecimal.ZERO) == 0) { + System.out.println("Cupom aceito com sucesso!"); + cupons.gravarJSON(); + return true; + } else { + System.out.println("Cupom aceito com sucesso. Faltam " + moedaEmReais(troco) + "."); + this.valor = troco; + cupons.gravarJSON(); + } + } else { + System.out.println("Cupom expirado! Favor escolher utilizar outro cupom ou escolher outro método de pagamento."); + cupons.gravarJSON(); + } + } else { + cupons.gravarJSON(); + System.out.println("Cupom expirado! Utilize um código ativo e dentro da validade, ou outro método de pagamento."); + System.out.println("Caso tenha tentado utilizar o cupom com troco de outro cupom, verifique se foi gerado um novo código."); + } + } + return false; + } + + private void gerarCupom(BigDecimal troco, Cupons cupons) { + Timestamp agora = new Timestamp(System.currentTimeMillis()); + Cupom novoCupom = new Cupom(troco, agora, true); + cupons.addCupom(novoCupom.getCodigo(), novoCupom); + + System.out.println("O valor excedente é de " + moedaEmReais(troco) + "."); + System.out.println("ATENÇÃO: anote o código do cupom no valor de " + moedaEmReais(troco) + ": " + novoCupom.getCodigo()); + System.out.println("Válido apenas para compras na Máquina de Café até " + novoCupom.getValidade()); + } + + public BigDecimal calcularQuantidadeDeDinheiro(BigDecimal valor, NotasEMoedas Real, BigDecimal contagem, boolean SegundaSugestao){ + int quantidadeDeREAL; + Real.setQuantidade(0); + + if(SegundaSugestao && !this.encontrouMaiorValor){ + quantidadeDeREAL = valor.divide(Real.getValor()).intValue(); + if (quantidadeDeREAL >= 1){ + this.encontrouMaiorValor = true; + } + } else { + quantidadeDeREAL = valor.subtract(contagem).divide(Real.getValor()).intValue(); + Real.setQuantidade(quantidadeDeREAL); + + return BigDecimal.valueOf(quantidadeDeREAL).multiply(Real.getValor()); + } + + return BigDecimal.ZERO; + } + + private void imprimirSugestoesDePagamentoEmDinheiro(){ + System.out.println("A melhor opção para pagamento em dinheiro é"); + System.out.println("Sugestão 1 - " + sugestaoPagamentoEmDinheiro(false)); + System.out.println("Sugestão 2 - " + sugestaoPagamentoEmDinheiro(true)); + } + + private String sugestaoPagamentoEmDinheiro(Boolean SegundaSugestao){ + BigDecimal contagemPrecoEmNotas = BigDecimal.ZERO; + BigDecimal contagemPrecoEmMoedas = BigDecimal.ZERO; + this.encontrouMaiorValor = false; + String SugestaoDeNotasEMoedas = ""; + + Integer precoInteger = this.valor.intValue(); + BigDecimal precoMoedas = this.valor.subtract(BigDecimal.valueOf(precoInteger)); + + NotasEMoedas Real[] = NotasEMoedas.values(); + + for (NotasEMoedas real : Real) { + boolean IsMoeda = (real.isMoeda() && real.getId() != 8); //ID da moeda de um real + + if(IsMoeda) { + contagemPrecoEmMoedas = contagemPrecoEmMoedas.add(calcularQuantidadeDeDinheiro(precoMoedas, real, contagemPrecoEmMoedas, SegundaSugestao)); + }else{ + contagemPrecoEmNotas = contagemPrecoEmNotas.add(calcularQuantidadeDeDinheiro(this.valor, real, contagemPrecoEmNotas, SegundaSugestao)); + } + } + + if (SegundaSugestao){ + System.out.println("-- ou --"); + } + + BigDecimal contagem = BigDecimal.ZERO; + for (NotasEMoedas real : Real) { + if (!String.valueOf(real.getQuantidade()).equals("0")){ + SugestaoDeNotasEMoedas += real.getQuantidade() + " unid. de " + real.toString() + ", "; + contagem = contagem.add(real.getValor().multiply(BigDecimal.valueOf(real.getQuantidade()))); + if(contagem.compareTo(this.valor) == 0){ break;} + } + } + + SugestaoDeNotasEMoedas = SugestaoDeNotasEMoedas.substring(0, (SugestaoDeNotasEMoedas.length() - 2)); + return SugestaoDeNotasEMoedas; + } + +} diff --git a/src/cafes/Receita.java b/src/main/java/br/com/movimentocodar/maquinadecafe/Receita.java similarity index 74% rename from src/cafes/Receita.java rename to src/main/java/br/com/movimentocodar/maquinadecafe/Receita.java index 6290a55..c5dd3f5 100644 --- a/src/cafes/Receita.java +++ b/src/main/java/br/com/movimentocodar/maquinadecafe/Receita.java @@ -1,5 +1,6 @@ -package cafes; +package br.com.movimentocodar.maquinadecafe; import java.util.ArrayList; +import java.util.List; public class Receita { private int quantidadeDeAgua; @@ -32,11 +33,9 @@ public void setQuantidadeDeLimao(int quantidadeDeLimao) { this.quantidadeDeLimao = quantidadeDeLimao; } - public void Processo(Acucar NivelDeAcucar, ReservatorioDeAgua AtualQuantidadeDeAgua){ - ArrayList ProcessoDaReceita = new ArrayList(); - String NivelZeroAcucar = Acucar.Nivel0.getQuantidadeDeAcucar(); + public void preparar(Acucar NivelDeAcucar){ + List ProcessoDaReceita = new ArrayList<>(); - AtualQuantidadeDeAgua.atualizarNiveisDeAgua(this.quantidadeDeAgua); if (this.ferverAgua){ ProcessoDaReceita.add("Fervendo água"); } @@ -57,16 +56,13 @@ public void Processo(Acucar NivelDeAcucar, ReservatorioDeAgua AtualQuantidadeDeA ProcessoDaReceita.add("Adicionando " + this.quantidadeDeLimao + "g de pó para chá sabor limão"); ProcessoDaReceita.add("Passando chá"); } - if(!NivelDeAcucar.getQuantidadeDeAcucar().equals(NivelZeroAcucar)){ - ProcessoDaReceita.add("Adicionando " + NivelDeAcucar.getQuantidadeDeAcucar() + " açúcar"); + if(!NivelDeAcucar.equals(Acucar.NIVEL_0)){ + ProcessoDaReceita.add("Adicionando " + NivelDeAcucar.getDescricao() + " açúcar"); } - Print(ProcessoDaReceita); - } - - private void Print(ArrayList ProcessoDaReceita){ - for(int i = 0; i < ProcessoDaReceita.size(); i++){ - System.out.println(ProcessoDaReceita.get(i)); + for(String processo: ProcessoDaReceita) { + System.out.println(processo); } } + } diff --git a/src/main/java/br/com/movimentocodar/maquinadecafe/ReservatorioDeAgua.java b/src/main/java/br/com/movimentocodar/maquinadecafe/ReservatorioDeAgua.java new file mode 100644 index 0000000..00ef16c --- /dev/null +++ b/src/main/java/br/com/movimentocodar/maquinadecafe/ReservatorioDeAgua.java @@ -0,0 +1,30 @@ +package br.com.movimentocodar.maquinadecafe; + +public class ReservatorioDeAgua { + private int quantidadeDeAgua; + + public ReservatorioDeAgua() { + this.quantidadeDeAgua = 1000; + } + + public boolean reservatorioDeAguaVazio(){ + String msgReservatorioDeAgua = this.quantidadeDeAgua >= 50? "suficiente para " + (this.quantidadeDeAgua / 50) + " bebidas." : "vazios."; + System.out.println("Reservatórios de água " + msgReservatorioDeAgua); + + if(this.quantidadeDeAgua >= 50){ + return false; + } + + return true; + } + + public void completarReservatorioDeAgua(){ + this.quantidadeDeAgua = 1000; + String msgReservatorioDeAgua = "suficiente para " + (this.quantidadeDeAgua / 50) + " bebidas."; + System.out.println("Reservatório de água completo, " + msgReservatorioDeAgua); + } + + public void liberarAguaParaUmaBebida(){ + this.quantidadeDeAgua -= 50; + } +} diff --git a/src/main/java/br/com/movimentocodar/maquinadecafe/teste.java b/src/main/java/br/com/movimentocodar/maquinadecafe/teste.java new file mode 100644 index 0000000..37ec071 --- /dev/null +++ b/src/main/java/br/com/movimentocodar/maquinadecafe/teste.java @@ -0,0 +1,173 @@ +package br.com.movimentocodar.maquinadecafe; + +public class teste { + + /* byte[] mapData = Files.readAllBytes(Paths.get("target/cupom.txt")); + Map cupomMap = new HashMap(); + + ObjectMapper objectMapper = new ObjectMapper(); + cupomMap = objectMapper.readValue(mapData, Cupom.class); + + Cupom cupomSelecionado = cupomMap.keySet(codigo); + + + + //read json file data to String + byte[] jsonData = Files.readAllBytes(Paths.get("employee.txt")); + +//create ObjectMapper instance + ObjectMapper objectMapper = new ObjectMapper(); + +//read JSON like DOM Parser + JsonNode rootNode = objectMapper.readTree(jsonData); + JsonNode idNode = rootNode.path("id"); + System.out.println("id = "+idNode.asInt()); + + JsonNode phoneNosNode = rootNode.path("phoneNumbers"); + Iterator elements = phoneNosNode.elements(); + while(elements.hasNext()){ + JsonNode phone = elements.next(); + System.out.println("Phone No = "+phone.asLong()); + } */ + + //return true; + + + /*File file = new File("target/cupom.txt"); + FileWriter fileWriter = new FileWriter(file, true); + ObjectMapper mapper = new ObjectMapper(); + try { + SequenceWriter seqWriter = mapper.writer().writeValuesAsArray(fileWriter); + + seqWriter.write(novoCupom); + + seqWriter.close(); + } catch (IOException e) { + e.printStackTrace(); + }*/ + + /*JsonGenerator jsonGenerator = new JsonFactory() + .createGenerator(new FileOutputStream("target/cupom.txt")); + //for pretty printing + jsonGenerator.setPrettyPrinter(new DefaultPrettyPrinter()); + + jsonGenerator.writeStartObject(); // start root object + jsonGenerator.writeStringField("codigo", codigo); + jsonGenerator.writeStringField("validade", validade); + jsonGenerator.writeBooleanField("ativo", true); + jsonGenerator.writeNumberField("valor", troco); + jsonGenerator.writeEndObject(); //closing root object + + jsonGenerator.flush(); + jsonGenerator.close();*/ + + + +/* + private void RegistraCupom(){ + } + + + // Java usando a biblioteca Jackson + + Fatura fatura = // Criação do objeto fatura. + + ObjectMapper mapper = new ObjectMapper(); + + String jsonString = mapper.writeValueAsString(fatura); // Objeto Java para JSON string. + + Fatura novamenteFatura = mapper.readValue(jsonString, Fatura.class); //JSON string para objeto Java. + + +String json = "{ \"color\" : \"Black\", \"type\" : \"BMW\" }"; +Map map + = objectMapper.readValue(json, new TypeReference>(){}); + + / + */ + + + + + /* package br.com.movimentocodar.maquinadecafe; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializerProvider; + +import java.io.IOException; + + public class cupomSerializer extends JsonSerializer { + + private ObjectMapper mapper = new ObjectMapper(); + + @Override + public void serialize(Cupom cupom, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException, JsonProcessingException { + mapper.writeValue(jsonGenerator, cupom); + jsonGenerator.writeObject(cupom); + *//* jsonGenerator.writeFieldName("codigo",cupom.getCodigo()); + jsonGenerator.writeFieldName("valor",cupom.getValor()); + jsonGenerator.writeFieldName("data",); + jsonGenerator.writeFieldName("ativo",);*//* + } + } +*/ + + + /* + byte[] mapData = Files.readAllBytes(Paths.get("target/cupom.json")); + + final ObjectMapper objectMapper = new ObjectMapper(); + Cupons[] cuponsJson = objectMapper.readValue(mapData, Cupons[].class); + + System.out.println(cuponsJson.toString()); + + + + + Map cupomMap = new HashMap(); + + ObjectMapper objectMapper = new ObjectMapper(); + cupomMap = objectMapper.readValue(mapData, Cupom.class); + */ + + + /* + final ObjectMapper objectMapper = new ObjectMapper(); + Map langList = objectMapper.readValue( + new File("target/cupom.json"), + new TypeReference>(){}); + + langList.forEach(x -> System.out.println(x.toString())); + + */ + + + /* JsonElement root = new JsonParser().parse(new FileReader("target/cupom.json")); + JsonObject object = root.getAsJsonObject(); + Gson gson = new Gson(); + for (Map.Entry entry : object.entrySet()) { + Cupom cupom = gson.fromJson(entry.getValue(), this); + System.out.println(cupom); + } + + + + // cupons.lerJSON();*/ + +/* + + ler json + + + final ObjectMapper objectMapper = new ObjectMapper(); + Map langList = objectMapper.readValue( + new File("langs.json"), + new TypeReference>(){}); + + langList.forEach(x -> System.out.println(x.toString()));*/ + + +} diff --git a/target/classes/br/com/movimentocodar/maquinadecafe/Acucar.class b/target/classes/br/com/movimentocodar/maquinadecafe/Acucar.class new file mode 100644 index 0000000000000000000000000000000000000000..5d7a31b83960f9e683af437f28e6f753caa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9!%^?7tG2PYzt z86O@nc(gC1CXLs z^3&Dl@;k%+gVgOjNPJN%ds>FIc4yWHoqQm4m!?Le?@~WiAMGeM|Mt%gqkg7FMIuh6 zal2&2-kAAfk7nx7wYwDQ`e@~tYoH9QBcSM-fm5!4w6Q^PlPY1}2<46NH(0nmh8OOS z(FnsUG{>O%iC8q`qyMkTN{Q&V(TPM{tG4PXbwohTr%!j;6u8fgc5Ph3C*~Hx@B~8mmp?tTFOXGmV1y>x}3aL_rT8bjIw~f6`w~D>sI=%6O zI3f`ufy9LyKMFD12wgbdK@mp);x&sRHSq+T~r|~lSQKEou0OORn)P>aYLYiWd?5^Fw&(M_zaU_yF1UV z+3}ELg`s(^CXxAhu&W3AD$9k*VTr_dp^1Q>a;{8v$<$YJ+9@a_8VWuKO zE=>>qgBn`V4+I|K5rJK*{AeW8ocxW|zB)8hF^+dI_2P-Z(`(ER7Sndw6!5GyoC?-M zhN9Q%5z##plMVH*PSx8{(pTAg*&kA+(KV4A_GG4QJ}Wx;xxS?F&t;Y66f(HSW|T$h zjkc&&TWnj~NJ*W3Dxg3wO^qU~5fm9c94(4IWuH)@6%hKx2AiPh|3LM`aVA(8qee;d zq_H}|tufa8uc$4#-*Dfj)!G=3?YB0@#uvI?z!t@I0tQ@)Wf~4A5)0Hs-~|@(3N<{V RT`_HkZL}$42q+fN`3vk4yXF7@ literal 0 HcmV?d00001 diff --git a/target/classes/br/com/movimentocodar/maquinadecafe/CafeComLeite.class b/target/classes/br/com/movimentocodar/maquinadecafe/CafeComLeite.class new file mode 100644 index 0000000000000000000000000000000000000000..3c4613acf14d1c77b90f19dbeb0ac047360ddc01 GIT binary patch literal 871 zcma)4%Wl&^6g`tVvE#Z)8`AP9k5FE=OXIY#A{C3ILaJn;LXo9*H?gPbAV0u$`VV{x zOC-`rAhBV`MOV zP}Whgpu=Er2f0UQUXq>5M5IL)W)aW5gnu5%lt&`uC&KHAfs8mqWml%Mc+Ie8@B1J5 zIrn0o4!y%7m+7$U1UgKH&3PE#i;#xlCaSR1Bufls`}o)is;FaG$BKmpZZLG_AtQyN zpC!JM$Dq%+8Mgd+zMjFmI#wB)Q&kBsPQ9KS?uk$)JT`EXLECP3IwqR9t>(SMuxkI$ z0yY0#3-@rJ6dmLu%*d@v;5F8+65q1$5F12xCW?0>o)+YDB=*EXrbJO!d*2BZ@Uev_ z3fQ~`oQhUWpINY{O+Tros^VJMR37S7P-ZhM*iJy4{VXEtx-V1lc9aZ6{(%o-sx(=dy0U||PKc!e5zG@M5W>#{XE*rtq}pjg6-e`|iz AzW@LL literal 0 HcmV?d00001 diff --git a/target/classes/br/com/movimentocodar/maquinadecafe/CafeScanner.class b/target/classes/br/com/movimentocodar/maquinadecafe/CafeScanner.class new file mode 100644 index 0000000000000000000000000000000000000000..48ce8e3055a1627dd4c4a4631990e55bc32be8bc GIT binary patch literal 6167 zcmbVQ`+FQ!8GdJPlZ0v0Y)IO)lq{u}WH;%y2?Uw|rA<`s$ucXzgX z2`va{DF_OPqR@g0R0Yv0wbCUPsh27$-tQL#R8ao~e^BFl&P;ZvY09(uJnih9lXK4Z zzVG*)?>lE+`_HM<0ItG6YT$uag-?SY0R;>8=#zRhsi()Io5%JT@w|e-Rc6}EU!%a= z(mJZ5Nrgc=P*QTKztBE{q?9a!{w4va_mezBz*O28J4Qqw9n)n1&$`0#h zwg#QJOvU9Iy2L837_d1jxFB!EtlNxiubwl+=qoj>LpNi?*jLb#xmnok$mwa_F6>>U z;c75?7K|BVW?jYr1QqO zk)<>lJ)1MwoQ2i#YU@A^HsLxI*J~KSdlanwpK&Ot9yjtEB})cq%Rp;ITE~mZ44+Gohdy(5#4Bx_Ze|Br6(2mw)bz@tf0{jwpo8Bs}bzba4UAw1G&N& z9WPSKY6rpW;SP$~-8I;S_o>h|j3KU|y%KG1)W>z17!+tJ%V6N8wivoe`r&ss?%rKN zD7Z-k@oo*{m|*C{^<=z|)U%^{(#j5`b4J!oSmia{lg~?L1bZ~>6_R-ML_$cE(vSw1 zsb)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L3HjzW-ICHSpFk#64!Z0+_(n*2p<7mXQp`PSr{ z!h264At5_z&k!ua7;5s9liBTW@{?}z$>~?*%l0z2E;0h5M6`yHww4FB4o2DK^nDjY z{0jD5$?N$#Ttg0hWE$g#o)N5*Z3aF^(U^-Gh`7%OS9&uB$WuZ$v1PH8~LT0dSsQq-8&)em1@HhC5VtIRm zzoR=4X$llEIfdIrgrQor?mT|TuRJ&XIu$H)wgaw@So-P5P4wV(RG^=%Zz%augyFaF zZOL$5iQzgY^n4uq9h@N~;m0NLPE$sk0||VW|Conx$v;U_!T0d0< z+2d>p&vugUY|n;Vo-L8}`;JMkzU4i}Y3?KvC)WghYS5>{r!(l6+CKd;4mjxVBzlqfR-HfbiR|}L`ZK~zGaGT5`1dh*vW&MJk>{}t zlM=C=_EtGKz05mvr9F?h=Q&Ue2TF4!_;GH5C(sZHenP%zk>F!;Q&2jWX!B_txSfu? zgSqxDm)Yi$Jk2h%EF??#`Bi*`b4=dFmMj`=f*jN6&Cek)95HD5jW e4Svht`F#5w&AuU@Z{aWOt6}@Ecn5z+(|-Y`wkxjy literal 0 HcmV?d00001 diff --git a/target/classes/br/com/movimentocodar/maquinadecafe/Cappuccino.class b/target/classes/br/com/movimentocodar/maquinadecafe/Cappuccino.class new file mode 100644 index 0000000000000000000000000000000000000000..a1ed2c9dd478ebe574c0f5aab6d8f265550cc946 GIT binary patch literal 908 zcma)4e`^y#5Ph3oa!I;P+L+dA{aLl%U2QH^t4NAqQ-ny6*2+Qq-{!I=E4jOPz4Vj# zMFe9&!4Kev5@*|kK=6-n-0aTm+nG0S_Rrs+zX9yyWgZ!ZVp9x4ro zd+tdRtFYIwJrhNS?RheOkiJxjD53zanJh76t+O-RE1-;J6Du4QTw|!slWf`?gPCS# z*lEvmH-$G$tTI$DdkRF-cMnwWQ2HtmgFLP?7`wH-dJ$FJ&}?rqtXlsQK(oKaaT|B2 zpQBj%5ovV=oXOhIt>5Fgk4;K;E|cSt2oqAdD-Y#S)Fj!ds@1YR4SdM)NCT@gz&42} zHQ+Iar2*?RfM%ZtIuMD}%p8vGOJ+mOOhU!sR_Wa3=}}D&g0v~qV+Atw z(`z6LEiG9_p9z<2oxHEe(hhj%WGiff1?LwEr-m`X;us}zs;8B;3D(EhaK59I|AD*d z`XF7m9NKJ*Ve7Rt#*=T9ErVUMTO=;9NY!#QeUmtG*jS>o5?&F%H&{jsD|kvMe#HXM N@SHq`J+c|R_y;?I+}QvC literal 0 HcmV?d00001 diff --git a/target/classes/br/com/movimentocodar/maquinadecafe/ChaDeLimao.class b/target/classes/br/com/movimentocodar/maquinadecafe/ChaDeLimao.class new file mode 100644 index 0000000000000000000000000000000000000000..d249ab92a7c9f3563ca5a9cb16aa0237d56d757e GIT binary patch literal 818 zcma)4%Wl&^6g`tVapJm88`AJ7lmMkTE{#)`b;Y8okSbY-QWUA(P3$3=$`5dz?)VtQ z7a$QLfyAaeKC0qQ6Hy7Vh(>cf_s-0@=brKJs~^7r>|v*j0)y2ZUVd(dq8Z8f@=Iz! zLs3V`gpM+U)6d)>jomoCkg-VeG)P09xiSAZk_it*z~2jZU-V_j8A^LHk@-u8hJEOt z@eA%oJQ=vhc_x#A*Xrpo7`EnNd@BMWb8eslQz=?W zAwLkljCsnS&zKpu{dw-rj(a**8S2+P#XKLn`*Ls~0^*FyxXqyLv^yOGb=*~I?=h^} z|1&_Tzi;9J)~TO2nFvTxV|wr(R!_CwH1PmV|?M1T>r-p2pczR9w zK~btA&rI0LADt4)NQMQw)gztVG!zU~Unb)9DDI2w9q&h!srhNZqaM$sif2hJAIfuv z&RkC2xa=_)$LS~w#4D+|t2bM1L<0v1b4<*bH2e^HooJbL#wqho~W-i#^zVLUceUNIuQc~VTs;J eClQNO#Ka3MVHXyj)2=x!hi$YeVsHry===e~4#p$^ literal 0 HcmV?d00001 diff --git a/target/classes/br/com/movimentocodar/maquinadecafe/Cupom.class b/target/classes/br/com/movimentocodar/maquinadecafe/Cupom.class new file mode 100644 index 0000000000000000000000000000000000000000..e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E*vxZ=^0E~j=td`&`86Kk;Z?lGCn9TJLf@&mifxZN#~{Lc9zQ}R zH_1vdIT8O0Evx7r3&vgT*khlL53J(RRqTt@ui`P@A78^0bq4Qy*Kp)z*8+em^ggW?yj3$Vp*tVA#4Uo(#F0Ej) z>}#{e+(}=(%*8J4r!%lC`7!a9_9O6i3H_+{#(KmfYq-pumm$@m6X+x49t~%bkSbh| zQh|3!JSbm+qxx1yiWmOiO;9Hl0k|Wmm;>XwlJUEEZv$iFZsWZh8s98=K1WxIWpnEb zYj{Z&Ym#-b$}m9?2N>_cikviuJn9+F`}jc9{}3OAj3x-Fn0KtfR*0)`SK-zEj=I|0 zk=y(b(J~BDewZRW!jvDYVA>JFf2`+?eE4uy%3zh7} literal 0 HcmV?d00001 diff --git a/target/classes/br/com/movimentocodar/maquinadecafe/Cupons.class b/target/classes/br/com/movimentocodar/maquinadecafe/Cupons.class new file mode 100644 index 0000000000000000000000000000000000000000..cfbb4ec5337a538534fe84597271d4df34e416e6 GIT binary patch literal 3220 zcmbVO*>V#{6g@2ok1fVFnAI$aNPu_)g#-v#X0e3{5Mw)t*eu!Fqp>{pEMjJ4Ap4$t zLSFNf;w@AqCO}mxRlMa#@)t=?&x~yuxq^}hwWho8J@?$LyZ`v>(Qg2T@Ld)uq%~x8 zY(R^^rg^z2^R{#=`H7i%(+CAxhAh_#PYa}bdZ#qB3T%#qYN2K4FUVl-vaDvIA>D?J z&^5H{=s>4H-;AF(JSXpXiE|7Jt7f^fY#MUb%ol4_&kY3H99dod?i^di zCw5^YHls_!79Cr$O`v_vE@@S3WO;T>8R-J)$tsjXGj?etKtcC)$u8XzU5X5N^YNy7x1FM27}>o1p3FCHdDxA7Y^t+ zh?fLf>Ccq3JzrpFPvU|j!@2y3RXJxGmLqM-_o7cjzm5SM5;)Y1rAb+lQA!1L$1}@v z)VX3xi+SuzV)wL_`uHV|Dx!HEFXM>7#+ay8W?cwuUFI4kGZF7%y}qjBD2@s2aO8qn z^jt%R(^fdguOO6eNc)%SbC+l~#<+219ex^KqkB=YSzi9UWt*)y$>I;CPqz6eHHYT| z&&}dE3aWpG1h%bXUv&-Jr>h=n+P6Z}&*Bu$D$QYTCz^?^!VRTXWbRcD&B}n{cN{xE zFO3D-%$H>-XDqjzv?=?fs_;gTR>OH6uj7KibGIWqDoE$dSy{8gN#6{^yOS(60t)0A z>ZT0Dgjp?@@P>vl9hWiQEV)>hE=FuvkTo+H4u*YS-W3>L^*gcgOhzU1R?Tz`bA{6+ z-qdhKM+sM1!O!q#tu~u1VkJlknl|DFw9zWdWp$wQ^g3G~*yWyV z=9r1}3%yeU9Za|9hQ9O@%rom?_BPGXQ3OLT<|3fkrhln4!FtZFq=z17D?Ts7WT!1K zZ^iY-rg>J&tSvDb6AbRQIB)Flx++lFnB~zz7gx5`QN#7DT3nqH%w)kr?CpM8yr?u%O}Bz=Y;`dU%hOGb6z>UJnE5!i@fm$y8lmU2*T1jNS|S*OUXX6tHiP|Rp0`k| z*5BOA1=C<5R=j$*YOW)Gv#v>2dbt6jC~dpMgSgO&&jpT*27#F~RMF<1+{=l9oa^Nl z)%BSxn}ce;_~ZxMDtkE@KDoz*!@M6Zx~}OLZAsNY!&d?a8mz46p@wgGI{&*U(;J5a z`}ihE@%~G5aBJ3^&>AK=X8#~5LT&W#^h!sx&f zE)Hh8Gb$QOn3(R)Ea9ymkyUF;xN)DTdvFXVh@Xy9*@rA~PjEcR91L=Ih_Ap?d|;iS z+z5Bha&?%qV#M||IUQuuZ8+pKNLDU9evw<^fqK|faf_C=@^R=RU>NpbKSI=KbCHtW zNc~OVjE0RGj%zrj(U8z^tp%&@r*WI2Dcr$b{x9I){Q#D+_ literal 0 HcmV?d00001 diff --git a/target/classes/br/com/movimentocodar/maquinadecafe/Main.class b/target/classes/br/com/movimentocodar/maquinadecafe/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..7ac682fd50eb4003d2c401782fd123a67135192e GIT binary patch literal 3882 zcmbVPX;U266+KTZJ&alr9t0ASjoOw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CAhO z-o#s6Pf$g+v%IaD_kS5*q4ckEzLD>*;cc$-_d$HKc$*RvT)V%9mRYLaI@b3W99qHS z_i%U()@^v_r|TZ!6XzNt$@VJLxyJU!732qv_WD+%cLfX4a(lxHynFxtJ7xG< zPEYS6lr;)<5vDV=8?>+qkFx+hfun4(kMY@qr`T*B!vK!s5>Bu|>SQ0&&3>a7d7NZH zOk)YBDC0CyID_xA!+ZzN;9Z=>GCRIEDD@ReJ&L{fCceenmWcJYIcnsYefSQ(%Z^q{ z`5w4?n;UiS7VA{D|`Fs7sc!KPJ*Y;m*UT{{TG(TK5 z`~a;6Ui}Ak-|D5Lu9>ly;PR}Fj}DFQ5@C!0yqo$AT{A|6x-~*u;-oFo?mRvF94)wj zL%2wsE^UdGjt$K_Dw-eQPsn#^>-Jcw!%und9{dbH=Q}|Qf5HD><2U?Da`X_t!ynN8 EA6cYOX#fBK literal 0 HcmV?d00001 diff --git a/target/classes/br/com/movimentocodar/maquinadecafe/MaquinaDeCafe.class b/target/classes/br/com/movimentocodar/maquinadecafe/MaquinaDeCafe.class new file mode 100644 index 0000000000000000000000000000000000000000..a8e9c22ed28a6fe638f6f7b59d41ae10db6b661a GIT binary patch literal 5123 zcmb7Ii+dE+76092lUbHQForkkq9{qoW+4b_5c^a z+iKrW`&9Zw+fv)wS_%P4E84WRYVG^|_z(IAwBOgS^mk`wlMSJM)BV1kxpViPbIk+wkYkf?4HrXD(?$4_E@&%_X^avv>q^! z6u2f>RPn81cDw7!<2lRoQ!r4!01IInSY+ZVEEd=_>Sps!DO++Ttdg>QC+`%bn=Q$s z70Z?dm6s2y>`?gBulo2Tkl@0Kz|!0m_UP97uQt(yYXqA1DNnf*(sx|T=~vswDpKIK zT%0ZEOLiMrD$o)~Seuzbvj%O2z{a>DeNHK-ET5vwwdiVrj(DQwawVU)Y$t_PTJXBK zg5$DZ<*bsV;I&$CZA?K89Vguj9JT#7(%F1dxRSL(>w*riLWltp`&KO^b5~DC(gl?!k*1$ccW&(5v^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$o~uU+<_aE`HT2oZNH<0bPyg+Y;VdZ zD$p2t+9zUf^{h5xhlNiXSnv{FuK7xmw2eH`x;WK#@vHb@o5(Y*r#;km@sIH1HjA^Zi|=T=_$T;jZSf=>9xs?) z#VM-U1bt_2;52C2JN&ER9mSpKr3>I+J>9FJ8s#s=n!ks|6#$mh?w7z8162fai@_?S z++wIo)VUb0qARy3RiWk<iDv+*()?( zQ9IR6?W;Pz?rZi5%{Npim)fO0rQ>N|bKp9jxr)R5ns{tBO8>KR zPTNMEo+1W1PKWRS&Cw4LpFB={^%T1BD!TDEvilcQ){QMJ4vkHsm)%c&9<1@h&+!`h d>A)}WOOi5q{}p|Ik3Z5cK8F1Xe<2_J{{gsdhDQJZ literal 0 HcmV?d00001 diff --git a/target/classes/br/com/movimentocodar/maquinadecafe/Pagamento.class b/target/classes/br/com/movimentocodar/maquinadecafe/Pagamento.class new file mode 100644 index 0000000000000000000000000000000000000000..326aa2c18c0374e6ee462160a5a4ab04bcda45ba GIT binary patch literal 8697 zcmb7J3w%`NmH&UqBzH2o5C{x1yc{ZM5|RucMoqL8k|046kN^s3-J6+9a%E<2xHA($ ztJbP(U2CoF+AY|%Vzp>1U8{AVxKg*-Zo76Lw%c0m_OaXDb=&T)>%O(MrT_EYJIN#j zH~xOfojc#-eCPQ;=R5P_Z%&*9aEaO%K?N!egiKVST4C1p)`*ozTiLXpB(72-pVbmCin5c!R&@$j9l5QrEaYvktoz1&RH)VN=jJ2=eWUZ8)wD#DE zE!Lo=Cl%({*`%Azdv2lEa$IkRm3BP^wM)p(G*O3H3RNTi=)6sumyDGkO007RyX>Ts zvC(z8s=M@*rHYz|wVz0FmKHB3#qv8M(LvBu%zCUTD zxp!4V&zW{KmQ9q2Tu)OiH*qe`Q#dPQ?X^4IY|_eK<>ZI>mdjh&d`_Y1Oj7wowN3l; z9%Y~o!)P?ogcS<2Gj`rhxm|XdnN&}ND_Tsnicg&DWQIK_<9PjrK|7as?OfU7?o5}H z9kLzIHLy}4F&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*9}1uH@^BH4wufV3pV?1ii5~Q&;6zg_JkEM) z)gjClHjnVcF_~iF<9Ol(=rtVWE;^{p9l^P>^pAq2M{t&m%FvfMB%jalv&`9E#szeb z2HrGU=y0u=jg|aiXBC6zd^*G$G;@AE+Su^DfGydJaShrrh)dwH>3#t3!_91e-->Q} z;dHSEXhr0^D-eF`_RT>pTY zi<{|Gx2P8O;nv`T>LT2x+VLUP&F)$+?oe0aPSwwgV-g=$4x3>a+@pr^5w)MKu3Paj zbvy1?_u%8|6ZoWd&PN#Z>lxVRs`KdJ&FEJRs*#dj!=IU&)Cyj#1~FeXbCp4vv#Nz- zm6Uu)wGtLWlw+n!$QU`>sn>-m$E#|kTE%svcuB2R=X2dl7$v{AlJaXfsxHu!U&mvr zO0GGg_ZZvcd%Nbq9AuL(JPa|KAQdT zIR3r8O5+}N`QM^R!MF+RKe~&KqGH1U}Kz)T^ z`YJ*62P%q}S=IblHQ^`PfH%^G2GOc|_-T^jTN6}#?5&XRduIG!#v|Qy;%VASGbz18J1hA u&kEJAw()Z{Pv1^Q-L0S3>gRR(Y3XNDKW+US)K5q4<-Q2_q*az_CH7msjauLU literal 0 HcmV?d00001 diff --git a/target/classes/br/com/movimentocodar/maquinadecafe/Receita.class b/target/classes/br/com/movimentocodar/maquinadecafe/Receita.class new file mode 100644 index 0000000000000000000000000000000000000000..003dfa4ae99aa4b03cf7e41c9ec68abc8281d94f GIT binary patch literal 3049 zcma)8+jA3D82_C%&8A^XY3Lma0Slz*C4wMGxL8^$)wC3fMT&~2o6~mbW;g6^Dpm1* zSG+wq;sYb&1LK>bz))u#XZj`&J~$))fPaOV|7ulGLE0Q5ugF!;M&dWJ|J}RkTQUT`@aFH}JR{ zRBV*ohGK5tG+o@_zQiUKn^)@V8Ez@q!m!@+P|nqjM6Yf0xs>j>VMI|GLOa9S0r>(m zZABNZ(F50DJ9a3DspvqQxJ$ZHjaOE_Nj5U`G+^sB7!yR5FBJbc+%0I36H{XW_dD7 z5>GLNC}C{w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6V1C literal 0 HcmV?d00001 diff --git a/target/classes/br/com/movimentocodar/maquinadecafe/ReservatorioDeAgua.class b/target/classes/br/com/movimentocodar/maquinadecafe/ReservatorioDeAgua.class new file mode 100644 index 0000000000000000000000000000000000000000..16510acb40990bee62276bd981ec9c263d868dfd GIT binary patch literal 1653 zcmbVN%W@k<6g_Rp9$Cn-GqEi{k{|~sv7KN+2q8qq!B%j^RSKj~Fa@kyqmJG2%(OBy za+Uc7et>OOY_j29z1CMRDd~ER|F&*xc#9eIMtZd%Ne)zfb-Euz{T-Mv$|R zFJTm80#ncAk*vDX->-hwdZwI6U~EJCI@%P-t*q{iqkwS>#S-2?N#IT^s5-{0dge%b z%8!g=+A^qm@_ASLvaKBXR8>D$p$d*pNoV4@jG=kSs2B=9V(_p_h$N??&Q({WWKgJFT^ zT+O0o5Kqcu8OSd@xvg596@g;YbOT52=$Mc4p!0f6JX3BP6NOPAJC9U!VA|p27~U`9 z4nDAOH}33*0?TJ3r2QjvsH*8Cr8Bo99nR~q!1uka$_&$>52fFBRk++R=CIqT4YJXr z>2rK?+)+c!zv;10?_RBU(y|bB>AFoFDGoe)w-9!pYDe?tsY-`bRYawgP!+Bh@R7j$ zDMhb-=H&}3ZB=>og0xmd0rv&2^c|m_X6-RID?*^O>-#FGyD|(_XklC6>Hu}a7_sm` z;PQW)@^wk+!xA5s5#E16$)|;@JlA}aDBt34lX}5#Y3+B2wez{xzry;F`w=Wto)Z*fU^R>N9lhdQx7U7wHFfI+>~!ItU;_97qxSj6Pq=X71oOae zxOi$dntPdlNxxi@bC&49Y>Uivoe19HT-}15m6>F?DT181lt-B=_o`2-I|sYwIn#RuqJj10BlxCU|@ R3C^dv6h0P3I1$XS_yrn$NOk}K literal 0 HcmV?d00001 diff --git a/target/cupom.json b/target/cupom.json new file mode 100644 index 0000000..bc5cd7b --- /dev/null +++ b/target/cupom.json @@ -0,0 +1,14 @@ +[ { + "NOV21-4907398655736" : { + "valor" : 3.50, + "validade" : "01/02/2022", + "ativo" : true, + "codigo" : "NOV21-4907398655736" + }, + "NOV21-4907398786602" : { + "valor" : 99.00, + "validade" : "01/02/2022", + "ativo" : true, + "codigo" : "NOV21-4907398786602" + } +} ] \ No newline at end of file diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..097b2d7 --- /dev/null +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,7 @@ +H:\Movimento_codar\intellij-workspace\DesafioMaquinaDeCafe\src\main\java\br\com\movimentocodar\maquinadecafe\Bebida.java +H:\Movimento_codar\intellij-workspace\DesafioMaquinaDeCafe\src\main\java\br\com\movimentocodar\maquinadecafe\Acucar.java +H:\Movimento_codar\intellij-workspace\DesafioMaquinaDeCafe\src\main\java\br\com\movimentocodar\maquinadecafe\NotasEMoedas.java +H:\Movimento_codar\intellij-workspace\DesafioMaquinaDeCafe\src\main\java\br\com\movimentocodar\maquinadecafe\MaquinaDeCafe.java +H:\Movimento_codar\intellij-workspace\DesafioMaquinaDeCafe\src\main\java\br\com\movimentocodar\maquinadecafe\Main.java +H:\Movimento_codar\intellij-workspace\DesafioMaquinaDeCafe\src\main\java\br\com\movimentocodar\maquinadecafe\Receita.java +H:\Movimento_codar\intellij-workspace\DesafioMaquinaDeCafe\src\main\java\br\com\movimentocodar\maquinadecafe\ReservatorioDeAgua.java From 64b136994421e8416f0bf9fd11f676886632324e Mon Sep 17 00:00:00 2001 From: Lilian Date: Tue, 2 Nov 2021 01:09:00 -0300 Subject: [PATCH 6/9] Atualizado com Jackson e cupom em base32 --- .idea/.gitignore | 2 +- ...aven__commons_codec_commons_codec_1_15.xml | 13 +++ DesafioMaquinaDeCafe.iml | 1 + pom.xml | 7 ++ .../maquinadecafe/CafeScanner.java | 10 +-- .../movimentocodar/maquinadecafe/Cupom.java | 45 ++++++++-- .../movimentocodar/maquinadecafe/Cupons.java | 28 +++++-- .../movimentocodar/maquinadecafe/Main.java | 13 ++- .../maquinadecafe/Pagamento.java | 77 ++++++++++++------ .../maquinadecafe/CafeScanner.class | Bin 6167 -> 6131 bytes .../movimentocodar/maquinadecafe/Cupom.class | Bin 3118 -> 4792 bytes .../movimentocodar/maquinadecafe/Cupons.class | Bin 3220 -> 0 bytes .../movimentocodar/maquinadecafe/Main.class | Bin 3882 -> 3556 bytes .../maquinadecafe/Pagamento.class | Bin 8697 -> 9986 bytes target/cupom.json | 76 ++++++++++++++--- 15 files changed, 205 insertions(+), 67 deletions(-) create mode 100644 .idea/libraries/Maven__commons_codec_commons_codec_1_15.xml delete mode 100644 target/classes/br/com/movimentocodar/maquinadecafe/Cupons.class diff --git a/.idea/.gitignore b/.idea/.gitignore index 89d3959..5360a32 100644 --- a/.idea/.gitignore +++ b/.idea/.gitignore @@ -2,7 +2,7 @@ /shelf/ /workspace.xml .idea -.idea/libraries +.idea/libraries/ /out/ src/main/java/br.com.movimentocodar.maquinadecafe/teste.java target/classes/ diff --git a/.idea/libraries/Maven__commons_codec_commons_codec_1_15.xml b/.idea/libraries/Maven__commons_codec_commons_codec_1_15.xml new file mode 100644 index 0000000..c88c2b7 --- /dev/null +++ b/.idea/libraries/Maven__commons_codec_commons_codec_1_15.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/DesafioMaquinaDeCafe.iml b/DesafioMaquinaDeCafe.iml index c6b41b1..401f1ca 100644 --- a/DesafioMaquinaDeCafe.iml +++ b/DesafioMaquinaDeCafe.iml @@ -17,5 +17,6 @@ + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 9bd0035..954d99b 100644 --- a/pom.xml +++ b/pom.xml @@ -33,5 +33,12 @@ gson 2.8.9 + + + commons-codec + commons-codec + 1.15 + + \ No newline at end of file diff --git a/src/main/java/br/com/movimentocodar/maquinadecafe/CafeScanner.java b/src/main/java/br/com/movimentocodar/maquinadecafe/CafeScanner.java index dd9e370..e949e2e 100644 --- a/src/main/java/br/com/movimentocodar/maquinadecafe/CafeScanner.java +++ b/src/main/java/br/com/movimentocodar/maquinadecafe/CafeScanner.java @@ -143,20 +143,20 @@ private void checarSair(String entry){ } } - public Cupom pedirCodigoCupom(Cupons cupons) { + public Cupom pedirCodigoCupom(Pagamento pagamento) { String entry = ""; do { System.out.println(this.mensagem); entry = Scanner.nextLine(); checarSair(entry); - } while(!CupomEncontrado(cupons, entry)); + } while(!cupomEncontrado(entry, pagamento)); - return (Cupom) cupons.encontrarCupom(entry); + return pagamento.encontrarCupom(entry); } - private boolean CupomEncontrado(Cupons cupons, String entry){ - if(cupons.encontrarCupom(entry) != null){ + private boolean cupomEncontrado(String entry, Pagamento pagamento){ + if(pagamento.encontrarCupom(entry) != null){ return true; } return false; diff --git a/src/main/java/br/com/movimentocodar/maquinadecafe/Cupom.java b/src/main/java/br/com/movimentocodar/maquinadecafe/Cupom.java index 0416e33..5065a01 100644 --- a/src/main/java/br/com/movimentocodar/maquinadecafe/Cupom.java +++ b/src/main/java/br/com/movimentocodar/maquinadecafe/Cupom.java @@ -1,6 +1,11 @@ package br.com.movimentocodar.maquinadecafe; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import org.apache.commons.codec.binary.Base32; + import java.math.BigDecimal; +import java.math.BigInteger; import java.sql.Timestamp; import java.time.LocalDate; import java.time.LocalDateTime; @@ -8,28 +13,48 @@ public class Cupom { BigDecimal valor; - LocalDateTime validade; - Timestamp agora; + String validade; Boolean ativo; String codigo; - public Cupom(BigDecimal valor, Timestamp agora, Boolean ativo) { + Timestamp agora; + + @JsonCreator + public Cupom(@JsonProperty("valor") BigDecimal valor,@JsonProperty("ativo") Boolean ativo,@JsonProperty("codigo") String codigo,@JsonProperty("validade") String validade) { this.valor = valor; this.ativo = ativo; - this.agora = agora; + this.codigo = codigo; + this.validade = validade; + } + + public Cupom(BigDecimal valor) { + this.agora = new Timestamp(System.currentTimeMillis()); + this.valor = valor; + this.ativo = true; gerarCodigo(); calcularValidade(); + cupomCriado(); + } + + private void cupomCriado() { + System.out.println("O valor excedente é de " + Pagamento.moedaEmReais(this.valor) + "."); + System.out.println("ATENÇÃO: anote o código do cupom no valor de " + Pagamento.moedaEmReais(this.valor) + ": " + this.getCodigo()); + System.out.println("Válido apenas para compras na Máquina de Café até " + this.getValidade()); } private void gerarCodigo(){ LocalDateTime dataString = this.agora.toLocalDateTime(); long cupomNum = this.agora.getTime() * 3; - this.codigo = dataString.getMonth().toString().substring(0, 3) + Integer.toString(dataString.getYear()).substring(2, 4) + "-" + Long.toString(cupomNum); + Base32 base32 = new Base32(-1,null,false); + String cupomStr = base32.encodeAsString(BigInteger.valueOf(cupomNum).toByteArray()); + //cupomStr = DigestUtils.sha1Hex(cupomStr); + this.codigo = dataString.getMonth().toString().substring(0, 3) + Integer.toString(dataString.getYear()).substring(2, 4) + "-" + cupomStr.substring(0,9); } public void calcularValidade() { + DateTimeFormatter formatoData = DateTimeFormatter.ofPattern("dd/MM/yyyy"); LocalDateTime dataValidade = this.agora.toLocalDateTime(); - this.validade = dataValidade.plusMonths(3); + this.validade = dataValidade.plusMonths(3).format(formatoData); } public void inativarCupom(){ @@ -45,12 +70,14 @@ public BigDecimal getValor() { } public String getValidade() { - DateTimeFormatter formatoData = DateTimeFormatter.ofPattern("dd/MM/yyyy"); - return this.validade.format(formatoData); + return this.validade; } public boolean checaValidade(){ - if (LocalDate.now().compareTo(this.validade.toLocalDate()) < 1){ + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("d/MM/yyyy"); + String date = this.validade; + LocalDate localDate = LocalDate.parse(date, formatter); + if (LocalDate.now().compareTo(localDate) < 1){ return true; } return false; diff --git a/src/main/java/br/com/movimentocodar/maquinadecafe/Cupons.java b/src/main/java/br/com/movimentocodar/maquinadecafe/Cupons.java index 8bacc11..a7292e9 100644 --- a/src/main/java/br/com/movimentocodar/maquinadecafe/Cupons.java +++ b/src/main/java/br/com/movimentocodar/maquinadecafe/Cupons.java @@ -1,15 +1,15 @@ +/* package br.com.movimentocodar.maquinadecafe; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SequenceWriter; +import com.google.gson.Gson; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; +import java.io.*; import java.util.HashMap; import java.util.Map; -public class Cupons { +public class Cupons{ private Map mapCupons = new HashMap<>(); String codigo; Cupom cupom; @@ -29,17 +29,28 @@ public String toString(){ return "Esse cupom é " + codigo + ", no valor de: " + Pagamento.moedaEmReais(cupom.getValor()) + ", válido até: " + cupom.getValidade() + "." ; } - /*public void lerJSON() throws IOException { - - JsonElement root = new JsonParser().parse(new FileReader("target/cupom.json")); + public void lerJSON() throws IOException { + */ +/*JsonElement root = new JsonParser().parse(new FileReader("target/cupom.json")); JsonObject object = root.getAsJsonObject(); Gson gson = new Gson(); for (Map.Entry entry : object.entrySet()) { Cupom cupom = gson.fromJson(entry.getValue(), this); System.out.println(cupom); } +*//* + + BufferedReader br = new BufferedReader(new FileReader("target/cupom.json")); + Cupons cuponsJSON = new Gson().fromJson(br, Cupons.class); + //this.mapCupons = cuponsJSON; + - }*/ + */ +/*InputStream inJson = Cupons.class.getResourceAsStream("target/cupom.json"); + Cupons cuponsJson = new ObjectMapper().readValue(inJson, Cupons.class);*//* + + + } public void gravarJSON() throws IOException { //append:true para ir adicionando itens em sequencia sem resetar arquivo @@ -56,3 +67,4 @@ public void gravarJSON() throws IOException { } } } +*/ diff --git a/src/main/java/br/com/movimentocodar/maquinadecafe/Main.java b/src/main/java/br/com/movimentocodar/maquinadecafe/Main.java index 6a4cff9..896f648 100644 --- a/src/main/java/br/com/movimentocodar/maquinadecafe/Main.java +++ b/src/main/java/br/com/movimentocodar/maquinadecafe/Main.java @@ -18,11 +18,10 @@ public class Main { public static void main(String[] args) throws JsonParseException, IOException { ReservatorioDeAgua ReservatorioDeAgua = new ReservatorioDeAgua(); - Cupons cupons = new Cupons(); - inicializarMaquina(ReservatorioDeAgua, cupons); + inicializarMaquina(ReservatorioDeAgua); } - static void inicializarMaquina(ReservatorioDeAgua ReservatorioDeAgua, Cupons cupons) throws JsonParseException, IOException { + static void inicializarMaquina(ReservatorioDeAgua ReservatorioDeAgua) throws JsonParseException, IOException { MaquinaDeCafe MaquinaDeCafe = new MaquinaDeCafe(ReservatorioDeAgua); if (MaquinaDeCafe.ReservatorioDeAgua.reservatorioDeAguaVazio()) { @@ -46,21 +45,21 @@ static void inicializarMaquina(ReservatorioDeAgua ReservatorioDeAgua, Cupons cup do { CafeScanner selecionarMetodoDePagamento = new CafeScanner("Digite 1 para pagamento em dinheiro, 2 para pagamento em cartão de débito e 3 para utilizar cupom."); int MetodoDePagamento = selecionarMetodoDePagamento.pedirMetodoDePagamentoAoUsuario(); - sucesso = Pagamento.executarCobranca(MetodoDePagamento, cupons); + sucesso = Pagamento.executarCobranca(MetodoDePagamento); }while(!sucesso); MaquinaDeCafe.determinarNivelDeAcucar(); MaquinaDeCafe.liberarBebida(); } - finalizacao(ReservatorioDeAgua, cupons); + finalizacao(ReservatorioDeAgua); } - private static void finalizacao(ReservatorioDeAgua ReservatorioDeAgua, Cupons cupons) throws JsonParseException, IOException{ + private static void finalizacao(ReservatorioDeAgua ReservatorioDeAgua) throws JsonParseException, IOException{ System.out.println("Retire a bebida e obrigado por utilizar a máquina de café."); CafeScanner finalizar = new CafeScanner("Digite 'sair' para sair ou 'iniciar' para comprar outra bebida.", "iniciar"); finalizar.pedirConfirmacaoUsuario(); - inicializarMaquina(ReservatorioDeAgua, cupons); + inicializarMaquina(ReservatorioDeAgua); } } diff --git a/src/main/java/br/com/movimentocodar/maquinadecafe/Pagamento.java b/src/main/java/br/com/movimentocodar/maquinadecafe/Pagamento.java index b5f0d26..76b3c51 100644 --- a/src/main/java/br/com/movimentocodar/maquinadecafe/Pagamento.java +++ b/src/main/java/br/com/movimentocodar/maquinadecafe/Pagamento.java @@ -1,16 +1,24 @@ package br.com.movimentocodar.maquinadecafe; -import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SequenceWriter; +import java.io.File; +import java.io.FileWriter; import java.io.IOException; import java.math.BigDecimal; import java.math.RoundingMode; -import java.sql.Timestamp; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; public class Pagamento { private BigDecimal valor; private boolean encontrouMaiorValor = false; private int metodoDePagamento; + private List cupons; public Pagamento(BigDecimal valor){ this.valor = valor; @@ -32,8 +40,37 @@ public static String moedaEmReais(BigDecimal valor) { return "R$ " + valor.setScale(2, RoundingMode.HALF_EVEN); } - public boolean executarCobranca(int MetodoDePagamento, Cupons cupons) throws JsonParseException, IOException { + public void lerJSON() throws IOException { + byte[] mapData = Files.readAllBytes(Paths.get("target/cupom.json")); + ObjectMapper mapper = new ObjectMapper(); + if (mapData.length > 0){ + this.cupons = new ArrayList(Arrays.asList(mapper.readValue(mapData, Cupom[].class))); + } else { + this.cupons = new ArrayList(); + } + } + + public void gravarJSON() throws IOException { + File file = new File("target/cupom.json"); + FileWriter fileWriter = new FileWriter(file, false); + ObjectMapper mapper = new ObjectMapper(); + try { + SequenceWriter seqWriter = mapper.writerWithDefaultPrettyPrinter().writeValues(fileWriter); + seqWriter.write(this.cupons); + + seqWriter.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + public Cupom encontrarCupom(String codigo){ + return this.cupons.stream().filter(c -> c.getCodigo().equals(codigo)).findAny().get(); + } + + public boolean executarCobranca(int MetodoDePagamento) throws IOException { this.metodoDePagamento = MetodoDePagamento; + if(this.cupons == null){ lerJSON();} //quando executar app // 1: Pagamento em dinheiro // 2: Pagamento em cartão de débito // 3: Utilizar voucher @@ -54,11 +91,10 @@ public boolean executarCobranca(int MetodoDePagamento, Cupons cupons) throws Jso BigDecimal troco = selecionarReais.pedirSelecaoReaisAoUsuario(this.valor); if(troco.compareTo(BigDecimal.ZERO) > 0){ - //cupons.lerJSON(); - gerarCupom(troco, cupons); - cupons.gravarJSON(); + Cupom novoCupom = new Cupom(troco); + this.cupons.add(novoCupom); + gravarJSON(); } - return true; } else { @@ -71,33 +107,34 @@ public boolean executarCobranca(int MetodoDePagamento, Cupons cupons) throws Jso System.out.println("Transação aprovada"); return true; }else if(MetodoDePagamento == 3) { - //cupons.lerJSON(); + //Cupom.lerJSON(); CafeScanner procurarCupom = new CafeScanner("Favor digitar o código do cupom."); - Cupom cupom = procurarCupom.pedirCodigoCupom(cupons); + Cupom cupom = procurarCupom.pedirCodigoCupom(this); if(cupom.getAtivo()) { if (cupom.checaValidade()) { cupom.inativarCupom(); BigDecimal troco = this.valor.subtract(cupom.getValor()); if (troco.compareTo(BigDecimal.ZERO) < 0) { troco = cupom.getValor().subtract(this.valor); - gerarCupom(troco, cupons); - cupons.gravarJSON(); + Cupom novoCupom = new Cupom(troco); + this.cupons.add(novoCupom); + gravarJSON(); return true; } else if (troco.compareTo(BigDecimal.ZERO) == 0) { System.out.println("Cupom aceito com sucesso!"); - cupons.gravarJSON(); + gravarJSON(); return true; } else { System.out.println("Cupom aceito com sucesso. Faltam " + moedaEmReais(troco) + "."); this.valor = troco; - cupons.gravarJSON(); + gravarJSON(); } } else { System.out.println("Cupom expirado! Favor escolher utilizar outro cupom ou escolher outro método de pagamento."); - cupons.gravarJSON(); + gravarJSON(); } } else { - cupons.gravarJSON(); + gravarJSON(); System.out.println("Cupom expirado! Utilize um código ativo e dentro da validade, ou outro método de pagamento."); System.out.println("Caso tenha tentado utilizar o cupom com troco de outro cupom, verifique se foi gerado um novo código."); } @@ -105,16 +142,6 @@ public boolean executarCobranca(int MetodoDePagamento, Cupons cupons) throws Jso return false; } - private void gerarCupom(BigDecimal troco, Cupons cupons) { - Timestamp agora = new Timestamp(System.currentTimeMillis()); - Cupom novoCupom = new Cupom(troco, agora, true); - cupons.addCupom(novoCupom.getCodigo(), novoCupom); - - System.out.println("O valor excedente é de " + moedaEmReais(troco) + "."); - System.out.println("ATENÇÃO: anote o código do cupom no valor de " + moedaEmReais(troco) + ": " + novoCupom.getCodigo()); - System.out.println("Válido apenas para compras na Máquina de Café até " + novoCupom.getValidade()); - } - public BigDecimal calcularQuantidadeDeDinheiro(BigDecimal valor, NotasEMoedas Real, BigDecimal contagem, boolean SegundaSugestao){ int quantidadeDeREAL; Real.setQuantidade(0); diff --git a/target/classes/br/com/movimentocodar/maquinadecafe/CafeScanner.class b/target/classes/br/com/movimentocodar/maquinadecafe/CafeScanner.class index 48ce8e3055a1627dd4c4a4631990e55bc32be8bc..58a85ebec42649115e05e2017f2d340be9d4de74 100644 GIT binary patch delta 1417 zcmZuwTWnKh9RGdiw6rU2x3=pUY%HfH;MQ%~SPBv-TVe(pBr~GX1e_sd>lCxLz{Ud- z-~mMCiR61Ak{E?3;5KeUrVd4si(EGEcZI3Q8*jWAL&V?ro%U=oB+cn}zVrY8F8|BE z`FC0ZSN|P53t%a3oeVtWk9Kd~P{=LMcNg*ln=(BGfn{=)HzxNR^Q z1DRYx2n1K;^Vv-ueVP9LY`+hG$OGX9aZ`?mpYjeuU`Wm_Z*Cl>TMJ%3gYdwIC_<=0 z7;{jLqr6SPH}N1&>i7|U^F!Q)=|hTnr|_Q6-dpiFvnMO+9#z>5T1A`7 z)`rs?t1jn-l`)aY0M3kL5|SFSaPHNEYy02ODz{yV*+6p3?*m zgxvIo6oIV>47`RtnxMUM*$&n1YOT7PPJ4LHB8gr! z^4y9Sb=OrNs#$48t?HL@{iR%gEt>HD{z~+dSrEI}l$Y7Q+1#$)9LJ+s{H9llGzUFir4E#a_m2bWA&Koa`_&=xZOC=`F>FLw+{GR{+ zInVhsv2C6``OooD08ile1NP%3p|+P_N^fjWb*EGPo04nO09f8^MP2X%e;d`WL00M&_`R9runea#b`{=M5Cf8Zm zj{~y9?}$OU*&lBiVk`&`*8o?G`yeV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TgRQ5dNT+J^Vc?T)!An`gw#sKzhqPa* zhuxAT@Yx$>Zrt+c-E_XW9$!WAHNG+Mt!hKxk!`ti+0K%?XeELi2AyeGrhM017PwWp zO2UZ&=y~a+GgiKD%ykzFxk>?q%C3+^mEqKK&e~x5wTk({hM%llE+NE_%w#5Q-%2*% z2g*x`eS&2kaU9DV%E)})${YBJ5?>eHMx+h=BCzBBQ@O^22(gPjwT6vcZI(Q8@Cwxe z^~f`T9(iWaBO5QrM(|*OC0=jv>2+Gya_ou!4G|w$ff3)gf=%(gD`<(YqJ#f!fAV_` zUg32I3|_a;qJ=oE*vxZ=^0E~j=td`&`86Kk;Z?lGCn9TJLf@&mifxZN#~{Lc9zQ}R zH_1vdIT8O0Evx7r3&vgT*khlL53J(RRqTt@ui`P@A78^0bq4Qy*Kp)z*8+em^ggW?yj3$Vp*tVA#4Uo(#F0Ej) z>}#{e+(}=(%*8J4r!%lC`7!a9_9O6i3H_+{#(KmfYq-pumm$@m6X+x49t~%bkSbh| zQh|3!JSbm+qxx1yiWmOiO;9Hl0k|Wmm;>XwlJUEEZv$iFZsWZh8s98=K1WxIWpnEb zYj{Z&Ym#-b$}m9?2N>_cikviuJn9+F`}jc9{}3OAj3x-Fn0KtfR*0)`SK-zEj=I|0 zk=y(b(J~BDewZRW!jvDYVA>JFf2`+?eE4uy%3zh7} diff --git a/target/classes/br/com/movimentocodar/maquinadecafe/Cupons.class b/target/classes/br/com/movimentocodar/maquinadecafe/Cupons.class deleted file mode 100644 index cfbb4ec5337a538534fe84597271d4df34e416e6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3220 zcmbVO*>V#{6g@2ok1fVFnAI$aNPu_)g#-v#X0e3{5Mw)t*eu!Fqp>{pEMjJ4Ap4$t zLSFNf;w@AqCO}mxRlMa#@)t=?&x~yuxq^}hwWho8J@?$LyZ`v>(Qg2T@Ld)uq%~x8 zY(R^^rg^z2^R{#=`H7i%(+CAxhAh_#PYa}bdZ#qB3T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Vh@Xy9*@rA~PjEcR91L=Ih_Ap?d|;iS z+z5Bha&?%qV#M||IUQuuZ8+pKNLDU9evw<^fqK|faf_C=@^R=RU>NpbKSI=KbCHtW zNc~OVjE0RGj%zrj(U8z^tp%&@r*WI2Dcr$b{x9I){Q#D+_ diff --git a/target/classes/br/com/movimentocodar/maquinadecafe/Main.class b/target/classes/br/com/movimentocodar/maquinadecafe/Main.class index 7ac682fd50eb4003d2c401782fd123a67135192e..761415d6da9421788e6cf5be9dd95dab99a0c727 100644 GIT binary patch delta 1387 zcmY*ZSx_8B82);9c4nDvmd$V^8(@JA#AUe5k_6=la)gKiDoIfAhyx5{l4Tc%!x)bZ z@s47GZK8Ou7nVMG)ItR-Rw_RE+&m-Ok7jsUoZT#g{}7-E94%B7!+JuNY@MXwUyu|ieD7KUBYAl+Sz}h}@XVa$Iw>6*syR$?z#9#RP|Hy# z!xrX9B4}j@ z$NG+0^H#%@HG8z7)0ynH$DAoE(NaC6BaVF>?I>pOcct7}d&aSH(1A`3T^!xmFEUD_ zd4Otkl#kk@&bU=RW4l)}<>Pkwq-$MSvFdg7;x-MpbM&EKTveK*A>6@nr^KI|a7Jy{ zayvIthPlGQ*n zquFP!f_+8{4<4max&Z@^(a1Lg@Hn0zD+g(uq9~c%OS3GRyAEx56*+x1Yta8M5`>qW z1@NN~JWUFg)rvMVuz=HK`3VXsn@)I=ER}pu;ThVcM?z~lgB>Tp8u>1)BQ#7PjlP;M zQIN&9Wo%zZ$*>VI%2yHXug#)r(-W)7qK3Zu{&mEMX@B=Bng`N#S+p&~_#C$wJz3mJ z0Rt;&CzBj^UBqF4b~h^0Rqk!}g?(AvzgMj*RI{+wU^gpaC5z+BfB!_ONttf0;URfj z?*?UqbW_7x2Do~GT8jWPOqY6FPi2=muL=)rWN>LN$=}j$Q7oMl6 zMeN2BnsA<;l4NX<_$Z^_$8+TMP_%(FwDM6-059N0Vr_wRwTPF9DdK5^PuZtMoW(g} zwvqI@g!Idl+)gqPc!dz3r_g*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;Z z0WVVYOSG@j{4&mxpB@z1l$xC-L?`(c3h<0k?Uh5JudyPBmGh`Bz(3}$cQ@p-Xc}(K zp}FV^g>nef*D+i`WQ_JV=CQR)@hUlNpNIQP^tCQ7^S64~$3$!aJ!5!B%M3n2}gG(>KqQp3SNsrWlDN|(APoU9Z{f`X+;e3IZ9 zV$$O9l>3Q1nuds^X2}tW<+fI;tnxO~?QWqSwqgag5mP;P=*9P6>AqW~SI~d=JT?1& gz1W-Zz6JXMKBU=6J$^*rXShTwovhDs8DGHrFRof31^@s6 diff --git a/target/classes/br/com/movimentocodar/maquinadecafe/Pagamento.class b/target/classes/br/com/movimentocodar/maquinadecafe/Pagamento.class index 326aa2c18c0374e6ee462160a5a4ab04bcda45ba..a1cb95e3a3fe66f6857a18c5c3193e70774be95c 100644 GIT binary patch literal 9986 zcmcIp3w%`7ng4&uOzvcI10fJ#1aVNryaT9+i69{Xi3Sh?LBL0EW^R&!nYm#eQM5km zqYrAetqRl!pf*0RDwY9ZWvy&$Yu$Fc??<=0?LOLdxBKXJU2U!Of6l#=Oaf@Szu*1{ zckVs+obP<+`~Khm`_8#m=}PUcPQkkX@&ln2wO3lxhxGDSN#m2vwh6bWKMoW?-g) zvrWvxIfAJp!q++3WHgrSTjfM;N?Y05x#EW9-OE=CrWXh+?A4;CpKan?oF@pR?Mzq1 zigWDz>W(vws3~|+u;fa*>U#%Z<(WH&{`MbA_EtjScpqbnPvs&;xuN;wxX@^__7@t^*G&| zZ?vSEEz1mCDyUP)?6uMvJ9Sec-n7+YnhARi(?`o+T&R!^-rc z&p^M47`BpLKV~7LN0U0WI)b)B>klL1cM?Xs^dfE|p|XNM5_i(J0dl7s{&Y^qn&me| z>;VOwAd=W_BBi=c98iwv$}rg0r>uxwh77U>22I?En*L$V?8Y5fUEoHb3w;Q;_#GSZ{ zOnQdds1un@W9d?F60PrPB%WDgHP_uH?!mnRqnB*cn%u#BGHQ)$wDFkIg7`E(W8kxj zVLz7-5ItwU3-erlXdz1&_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lh+;BNN z?c;_Q%L)<;Z}EDvDVt>2UcURD!pXjIoH~W4i2l*OmZ)bO&z!>7J3Xx-Pa%)z`NRuE zQHuk0H<5-R_pc^NM`zM{W)-v^a0%|q;ugksd zT!P!CcwNiZ$b5(Ox5=f1rQ6Y43yb;XmlLawu>%dnV^Mc{g@v0 ze=m-F#LX@i@bd}$$JypYbYmUSoByvr#iQsHZ)W41h%eLigcCdulg--iRLm}Y9W3tY zx|h3`5nfSNhE!A88*#Iqf&c9E6nX8(yV;TacWy7&uX9mevICu9}Gc~neDB|v&NDZ(p`ycpZhxRH9Zp*~;b?Jvj- zeFB{C_%7724o|Zm&#*{eW#-Sa^Iyj-j!_KH6U^V>p8+qBSYAX5-^8sPi9?h*K z{Z%u^So7LDxRTnOB#kVWY>};eFXHywh^!s5Z7E;xcYa*sJZ Date: Tue, 2 Nov 2021 18:34:32 -0300 Subject: [PATCH 7/9] =?UTF-8?q?Altera=C3=A7=C3=B5es=20classe=20Cupons?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...Maven__org_mockito_mockito_all_1_10_19.xml | 13 ++ DesafioMaquinaDeCafe.iml | 1 + pom.xml | 8 +- .../maquinadecafe/CafeScanner.java | 10 +- .../movimentocodar/maquinadecafe/Cupons.java | 67 +++---- .../movimentocodar/maquinadecafe/Main.java | 13 +- .../maquinadecafe/Pagamento.java | 58 +----- .../movimentocodar/maquinadecafe/teste.java | 173 ------------------ .../maquinadecafe/CafeScanner.class | Bin 6131 -> 6167 bytes .../movimentocodar/maquinadecafe/Cupons.class | Bin 0 -> 3927 bytes .../movimentocodar/maquinadecafe/Main.class | Bin 3556 -> 3865 bytes .../maquinadecafe/Pagamento.class | Bin 9986 -> 7263 bytes target/cupom.json | 5 + 13 files changed, 71 insertions(+), 277 deletions(-) create mode 100644 .idea/libraries/Maven__org_mockito_mockito_all_1_10_19.xml delete mode 100644 src/main/java/br/com/movimentocodar/maquinadecafe/teste.java create mode 100644 target/classes/br/com/movimentocodar/maquinadecafe/Cupons.class diff --git a/.idea/libraries/Maven__org_mockito_mockito_all_1_10_19.xml b/.idea/libraries/Maven__org_mockito_mockito_all_1_10_19.xml new file mode 100644 index 0000000..c87b108 --- /dev/null +++ b/.idea/libraries/Maven__org_mockito_mockito_all_1_10_19.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/DesafioMaquinaDeCafe.iml b/DesafioMaquinaDeCafe.iml index 401f1ca..67cf504 100644 --- a/DesafioMaquinaDeCafe.iml +++ b/DesafioMaquinaDeCafe.iml @@ -18,5 +18,6 @@ + \ No newline at end of file diff --git a/pom.xml b/pom.xml index 954d99b..c10a84b 100644 --- a/pom.xml +++ b/pom.xml @@ -39,6 +39,12 @@ commons-codec 1.15 - + + + org.mockito + mockito-all + 1.10.19 + test + \ No newline at end of file diff --git a/src/main/java/br/com/movimentocodar/maquinadecafe/CafeScanner.java b/src/main/java/br/com/movimentocodar/maquinadecafe/CafeScanner.java index e949e2e..a9eafd1 100644 --- a/src/main/java/br/com/movimentocodar/maquinadecafe/CafeScanner.java +++ b/src/main/java/br/com/movimentocodar/maquinadecafe/CafeScanner.java @@ -143,20 +143,20 @@ private void checarSair(String entry){ } } - public Cupom pedirCodigoCupom(Pagamento pagamento) { + public Cupom pedirCodigoCupom(Cupons cupons) { String entry = ""; do { System.out.println(this.mensagem); entry = Scanner.nextLine(); checarSair(entry); - } while(!cupomEncontrado(entry, pagamento)); + } while(!cupomEncontrado(entry, cupons)); - return pagamento.encontrarCupom(entry); + return cupons.encontrarCupom(entry); } - private boolean cupomEncontrado(String entry, Pagamento pagamento){ - if(pagamento.encontrarCupom(entry) != null){ + private boolean cupomEncontrado(String entry, Cupons cupons){ + if(cupons.encontrarCupom(entry) != null){ return true; } return false; diff --git a/src/main/java/br/com/movimentocodar/maquinadecafe/Cupons.java b/src/main/java/br/com/movimentocodar/maquinadecafe/Cupons.java index a7292e9..0b707d5 100644 --- a/src/main/java/br/com/movimentocodar/maquinadecafe/Cupons.java +++ b/src/main/java/br/com/movimentocodar/maquinadecafe/Cupons.java @@ -1,70 +1,55 @@ -/* package br.com.movimentocodar.maquinadecafe; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SequenceWriter; -import com.google.gson.Gson; -import java.io.*; -import java.util.HashMap; -import java.util.Map; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; public class Cupons{ - private Map mapCupons = new HashMap<>(); - String codigo; - Cupom cupom; + private List cupons; - public Cupons(){} - - public void addCupom(String codigo, Cupom cupom){ - this.mapCupons.put(codigo, cupom); + public Cupons() throws IOException { + if(this.cupons == null){ lerJSON();} //quando executar app } - public Cupom encontrarCupom(String codigo){ - return (Cupom)this.mapCupons.get(codigo); + public void addNovoCupom(Cupom cupom) throws IOException { + this.cupons.add(cupom); + this.gravarJSON(); } - @Override - public String toString(){ - return "Esse cupom é " + codigo + ", no valor de: " + Pagamento.moedaEmReais(cupom.getValor()) + ", válido até: " + cupom.getValidade() + "." ; + public Cupom encontrarCupom(String codigo){ + return this.cupons.stream().filter(c -> c.getCodigo().equals(codigo)).findAny().get(); } public void lerJSON() throws IOException { - */ -/*JsonElement root = new JsonParser().parse(new FileReader("target/cupom.json")); - JsonObject object = root.getAsJsonObject(); - Gson gson = new Gson(); - for (Map.Entry entry : object.entrySet()) { - Cupom cupom = gson.fromJson(entry.getValue(), this); - System.out.println(cupom); + byte[] mapData = Files.readAllBytes(Paths.get("target/cupom.json")); + ObjectMapper mapper = new ObjectMapper(); + if (mapData.length > 0){ + this.cupons = new ArrayList(Arrays.asList(mapper.readValue(mapData, Cupom[].class))); + } else { + this.cupons = new ArrayList(); } -*//* - - BufferedReader br = new BufferedReader(new FileReader("target/cupom.json")); - Cupons cuponsJSON = new Gson().fromJson(br, Cupons.class); - //this.mapCupons = cuponsJSON; - - - */ -/*InputStream inJson = Cupons.class.getResourceAsStream("target/cupom.json"); - Cupons cuponsJson = new ObjectMapper().readValue(inJson, Cupons.class);*//* - - } public void gravarJSON() throws IOException { - //append:true para ir adicionando itens em sequencia sem resetar arquivo File file = new File("target/cupom.json"); FileWriter fileWriter = new FileWriter(file, false); ObjectMapper mapper = new ObjectMapper(); try { - SequenceWriter seqWriter = mapper.writerWithDefaultPrettyPrinter().writeValuesAsArray(fileWriter); - seqWriter.write(mapCupons); + SequenceWriter seqWriter = mapper.writerWithDefaultPrettyPrinter().writeValues(fileWriter); + seqWriter.write(this.cupons); seqWriter.close(); } catch (IOException e) { e.printStackTrace(); } } -} -*/ + +} \ No newline at end of file diff --git a/src/main/java/br/com/movimentocodar/maquinadecafe/Main.java b/src/main/java/br/com/movimentocodar/maquinadecafe/Main.java index 896f648..6a4cff9 100644 --- a/src/main/java/br/com/movimentocodar/maquinadecafe/Main.java +++ b/src/main/java/br/com/movimentocodar/maquinadecafe/Main.java @@ -18,10 +18,11 @@ public class Main { public static void main(String[] args) throws JsonParseException, IOException { ReservatorioDeAgua ReservatorioDeAgua = new ReservatorioDeAgua(); - inicializarMaquina(ReservatorioDeAgua); + Cupons cupons = new Cupons(); + inicializarMaquina(ReservatorioDeAgua, cupons); } - static void inicializarMaquina(ReservatorioDeAgua ReservatorioDeAgua) throws JsonParseException, IOException { + static void inicializarMaquina(ReservatorioDeAgua ReservatorioDeAgua, Cupons cupons) throws JsonParseException, IOException { MaquinaDeCafe MaquinaDeCafe = new MaquinaDeCafe(ReservatorioDeAgua); if (MaquinaDeCafe.ReservatorioDeAgua.reservatorioDeAguaVazio()) { @@ -45,21 +46,21 @@ static void inicializarMaquina(ReservatorioDeAgua ReservatorioDeAgua) throws Jso do { CafeScanner selecionarMetodoDePagamento = new CafeScanner("Digite 1 para pagamento em dinheiro, 2 para pagamento em cartão de débito e 3 para utilizar cupom."); int MetodoDePagamento = selecionarMetodoDePagamento.pedirMetodoDePagamentoAoUsuario(); - sucesso = Pagamento.executarCobranca(MetodoDePagamento); + sucesso = Pagamento.executarCobranca(MetodoDePagamento, cupons); }while(!sucesso); MaquinaDeCafe.determinarNivelDeAcucar(); MaquinaDeCafe.liberarBebida(); } - finalizacao(ReservatorioDeAgua); + finalizacao(ReservatorioDeAgua, cupons); } - private static void finalizacao(ReservatorioDeAgua ReservatorioDeAgua) throws JsonParseException, IOException{ + private static void finalizacao(ReservatorioDeAgua ReservatorioDeAgua, Cupons cupons) throws JsonParseException, IOException{ System.out.println("Retire a bebida e obrigado por utilizar a máquina de café."); CafeScanner finalizar = new CafeScanner("Digite 'sair' para sair ou 'iniciar' para comprar outra bebida.", "iniciar"); finalizar.pedirConfirmacaoUsuario(); - inicializarMaquina(ReservatorioDeAgua); + inicializarMaquina(ReservatorioDeAgua, cupons); } } diff --git a/src/main/java/br/com/movimentocodar/maquinadecafe/Pagamento.java b/src/main/java/br/com/movimentocodar/maquinadecafe/Pagamento.java index 76b3c51..a4bda7e 100644 --- a/src/main/java/br/com/movimentocodar/maquinadecafe/Pagamento.java +++ b/src/main/java/br/com/movimentocodar/maquinadecafe/Pagamento.java @@ -1,24 +1,13 @@ package br.com.movimentocodar.maquinadecafe; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SequenceWriter; - -import java.io.File; -import java.io.FileWriter; import java.io.IOException; import java.math.BigDecimal; import java.math.RoundingMode; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; public class Pagamento { private BigDecimal valor; private boolean encontrouMaiorValor = false; private int metodoDePagamento; - private List cupons; public Pagamento(BigDecimal valor){ this.valor = valor; @@ -40,37 +29,9 @@ public static String moedaEmReais(BigDecimal valor) { return "R$ " + valor.setScale(2, RoundingMode.HALF_EVEN); } - public void lerJSON() throws IOException { - byte[] mapData = Files.readAllBytes(Paths.get("target/cupom.json")); - ObjectMapper mapper = new ObjectMapper(); - if (mapData.length > 0){ - this.cupons = new ArrayList(Arrays.asList(mapper.readValue(mapData, Cupom[].class))); - } else { - this.cupons = new ArrayList(); - } - } - - public void gravarJSON() throws IOException { - File file = new File("target/cupom.json"); - FileWriter fileWriter = new FileWriter(file, false); - ObjectMapper mapper = new ObjectMapper(); - try { - SequenceWriter seqWriter = mapper.writerWithDefaultPrettyPrinter().writeValues(fileWriter); - seqWriter.write(this.cupons); - - seqWriter.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - - public Cupom encontrarCupom(String codigo){ - return this.cupons.stream().filter(c -> c.getCodigo().equals(codigo)).findAny().get(); - } - - public boolean executarCobranca(int MetodoDePagamento) throws IOException { + public boolean executarCobranca(int MetodoDePagamento, Cupons cupons) throws IOException { this.metodoDePagamento = MetodoDePagamento; - if(this.cupons == null){ lerJSON();} //quando executar app + cupons.lerJSON(); // 1: Pagamento em dinheiro // 2: Pagamento em cartão de débito // 3: Utilizar voucher @@ -92,8 +53,7 @@ public boolean executarCobranca(int MetodoDePagamento) throws IOException { if(troco.compareTo(BigDecimal.ZERO) > 0){ Cupom novoCupom = new Cupom(troco); - this.cupons.add(novoCupom); - gravarJSON(); + cupons.addNovoCupom(novoCupom); } return true; @@ -107,9 +67,8 @@ public boolean executarCobranca(int MetodoDePagamento) throws IOException { System.out.println("Transação aprovada"); return true; }else if(MetodoDePagamento == 3) { - //Cupom.lerJSON(); CafeScanner procurarCupom = new CafeScanner("Favor digitar o código do cupom."); - Cupom cupom = procurarCupom.pedirCodigoCupom(this); + Cupom cupom = procurarCupom.pedirCodigoCupom(cupons); if(cupom.getAtivo()) { if (cupom.checaValidade()) { cupom.inativarCupom(); @@ -117,28 +76,25 @@ public boolean executarCobranca(int MetodoDePagamento) throws IOException { if (troco.compareTo(BigDecimal.ZERO) < 0) { troco = cupom.getValor().subtract(this.valor); Cupom novoCupom = new Cupom(troco); - this.cupons.add(novoCupom); - gravarJSON(); + cupons.addNovoCupom(novoCupom); return true; } else if (troco.compareTo(BigDecimal.ZERO) == 0) { System.out.println("Cupom aceito com sucesso!"); - gravarJSON(); + cupons.gravarJSON(); return true; } else { System.out.println("Cupom aceito com sucesso. Faltam " + moedaEmReais(troco) + "."); this.valor = troco; - gravarJSON(); } } else { System.out.println("Cupom expirado! Favor escolher utilizar outro cupom ou escolher outro método de pagamento."); - gravarJSON(); } } else { - gravarJSON(); System.out.println("Cupom expirado! Utilize um código ativo e dentro da validade, ou outro método de pagamento."); System.out.println("Caso tenha tentado utilizar o cupom com troco de outro cupom, verifique se foi gerado um novo código."); } } + cupons.gravarJSON(); return false; } diff --git a/src/main/java/br/com/movimentocodar/maquinadecafe/teste.java b/src/main/java/br/com/movimentocodar/maquinadecafe/teste.java deleted file mode 100644 index 37ec071..0000000 --- a/src/main/java/br/com/movimentocodar/maquinadecafe/teste.java +++ /dev/null @@ -1,173 +0,0 @@ -package br.com.movimentocodar.maquinadecafe; - -public class teste { - - /* byte[] mapData = Files.readAllBytes(Paths.get("target/cupom.txt")); - Map cupomMap = new HashMap(); - - ObjectMapper objectMapper = new ObjectMapper(); - cupomMap = objectMapper.readValue(mapData, Cupom.class); - - Cupom cupomSelecionado = cupomMap.keySet(codigo); - - - - //read json file data to String - byte[] jsonData = Files.readAllBytes(Paths.get("employee.txt")); - -//create ObjectMapper instance - ObjectMapper objectMapper = new ObjectMapper(); - -//read JSON like DOM Parser - JsonNode rootNode = objectMapper.readTree(jsonData); - JsonNode idNode = rootNode.path("id"); - System.out.println("id = "+idNode.asInt()); - - JsonNode phoneNosNode = rootNode.path("phoneNumbers"); - Iterator elements = phoneNosNode.elements(); - while(elements.hasNext()){ - JsonNode phone = elements.next(); - System.out.println("Phone No = "+phone.asLong()); - } */ - - //return true; - - - /*File file = new File("target/cupom.txt"); - FileWriter fileWriter = new FileWriter(file, true); - ObjectMapper mapper = new ObjectMapper(); - try { - SequenceWriter seqWriter = mapper.writer().writeValuesAsArray(fileWriter); - - seqWriter.write(novoCupom); - - seqWriter.close(); - } catch (IOException e) { - e.printStackTrace(); - }*/ - - /*JsonGenerator jsonGenerator = new JsonFactory() - .createGenerator(new FileOutputStream("target/cupom.txt")); - //for pretty printing - jsonGenerator.setPrettyPrinter(new DefaultPrettyPrinter()); - - jsonGenerator.writeStartObject(); // start root object - jsonGenerator.writeStringField("codigo", codigo); - jsonGenerator.writeStringField("validade", validade); - jsonGenerator.writeBooleanField("ativo", true); - jsonGenerator.writeNumberField("valor", troco); - jsonGenerator.writeEndObject(); //closing root object - - jsonGenerator.flush(); - jsonGenerator.close();*/ - - - -/* - private void RegistraCupom(){ - } - - - // Java usando a biblioteca Jackson - - Fatura fatura = // Criação do objeto fatura. - - ObjectMapper mapper = new ObjectMapper(); - - String jsonString = mapper.writeValueAsString(fatura); // Objeto Java para JSON string. - - Fatura novamenteFatura = mapper.readValue(jsonString, Fatura.class); //JSON string para objeto Java. - - -String json = "{ \"color\" : \"Black\", \"type\" : \"BMW\" }"; -Map map - = objectMapper.readValue(json, new TypeReference>(){}); - - / - */ - - - - - /* package br.com.movimentocodar.maquinadecafe; - -import com.fasterxml.jackson.core.JsonGenerator; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.JsonSerializer; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializerProvider; - -import java.io.IOException; - - public class cupomSerializer extends JsonSerializer { - - private ObjectMapper mapper = new ObjectMapper(); - - @Override - public void serialize(Cupom cupom, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException, JsonProcessingException { - mapper.writeValue(jsonGenerator, cupom); - jsonGenerator.writeObject(cupom); - *//* jsonGenerator.writeFieldName("codigo",cupom.getCodigo()); - jsonGenerator.writeFieldName("valor",cupom.getValor()); - jsonGenerator.writeFieldName("data",); - jsonGenerator.writeFieldName("ativo",);*//* - } - } -*/ - - - /* - byte[] mapData = Files.readAllBytes(Paths.get("target/cupom.json")); - - final ObjectMapper objectMapper = new ObjectMapper(); - Cupons[] cuponsJson = objectMapper.readValue(mapData, Cupons[].class); - - System.out.println(cuponsJson.toString()); - - - - - Map cupomMap = new HashMap(); - - ObjectMapper objectMapper = new ObjectMapper(); - cupomMap = objectMapper.readValue(mapData, Cupom.class); - */ - - - /* - final ObjectMapper objectMapper = new ObjectMapper(); - Map langList = objectMapper.readValue( - new File("target/cupom.json"), - new TypeReference>(){}); - - langList.forEach(x -> System.out.println(x.toString())); - - */ - - - /* JsonElement root = new JsonParser().parse(new FileReader("target/cupom.json")); - JsonObject object = root.getAsJsonObject(); - Gson gson = new Gson(); - for (Map.Entry entry : object.entrySet()) { - Cupom cupom = gson.fromJson(entry.getValue(), this); - System.out.println(cupom); - } - - - - // cupons.lerJSON();*/ - -/* - - ler json - - - final ObjectMapper objectMapper = new ObjectMapper(); - Map langList = objectMapper.readValue( - new File("langs.json"), - new TypeReference>(){}); - - langList.forEach(x -> System.out.println(x.toString()));*/ - - -} diff --git a/target/classes/br/com/movimentocodar/maquinadecafe/CafeScanner.class b/target/classes/br/com/movimentocodar/maquinadecafe/CafeScanner.class index 58a85ebec42649115e05e2017f2d340be9d4de74..9d6ed8bc47cedd38d94daa45d59f007d35e195e0 100644 GIT binary patch delta 1310 zcmZuwS!_&E82-+^)84wKGo6{vln!ns7*ma+M5zj?B@qM(Ni9K(kkCpR4~XSSVhzp% z@j^UU+uEx3eXo7r_wB`-7Y~B(oSC^DBDp#D-2eXnxBTZn-;1~OvRi(gJPTkDz8r;sVj?5wy_&~EbR4SANI@bW-K%D>&T9*Z-%%e*SFm#T4bqr zj#1fN-t)$dnmT#MTWn`mYXpI!RJ1g^zweoi=Xhb^r56+MN-oR3?7R_ZH?*K?cGbLD zGYe+dRoBj+t9Em0=M{)7ypuD09mGeu%vb37EYL}=^mURqe0?(NA<(ed-%~WoVt>?s zfG!GPa_xwNI3z3mj%bjJ{qgcf#)9y04RE!%4-)fhSD1ikIBU2H` zxBh`-$j@;~TJz({d=uSpMCUiLHVfh>ObaEfJBnsqJwInGt54;`Myl#Ut)kpzE5|V$ zXP$|H8pl8pHJ-ppM*c-Sg=rcw9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9T`j!Ylp(`ZS)Q-89Dc@O{q2{=^vF65~3$c>2DLj{w(kPljIy6x5M_7Z1F? ziYfH~_N1`7SFyVB1N@Nh+1^(bdzHVWB15^uE&srgYxw9j953BKae4)3M)L2xh`s$c zaCUkipL?{9bMNBOYZzI<_*+n~VoUUD1(O`DNxYjTfo^PO*gE+aVK?sMskINMaUi1A z9Rnt`Hse7&i|0tHlehNg@goWphamG`98vLO6-BK{9{&5`8Y$0z7?w?Zp1y&p>D=KJ zOq2P=>3quyJ~NW|FnX{KF;ItfEZdcpGS+cvsw-Q^<*U%-Tpdeq5Pc6h9%YE*H0g&% zyYf5FBpKk_LF||RCU{sMA>*Ssgkw02Qyj?@I!R9ZDeF)0Q*t^+RzJhf`HS2VKQ%mr zU*MNSlJ_k`^BxUnnRF_qR9vLzG6lodHTOF-S*kQ5-9JGS89v+c zbu2UWzVsRgaq8Wi25nLBxd3f=IZC+}yb`VdHGadVEP~(C`#<3|{1q~q8fX57H<@Bx F?*qBdENlP( literal 0 HcmV?d00001 diff --git a/target/classes/br/com/movimentocodar/maquinadecafe/Main.class b/target/classes/br/com/movimentocodar/maquinadecafe/Main.class index 761415d6da9421788e6cf5be9dd95dab99a0c727..05964ff7a4e24399357877cdad58adb589c6f643 100644 GIT binary patch delta 1476 zcmY*ZTXR!Y6#jN{a!zu(+s33Rq=hssZAsI#=>;NfDU{w6Z7Wo)7C|@-hmw*eF>SDb z8dOBVYuy#C;QayuGJ`rvhd4a>qtyyt$o&B-@1J}zf~{$ z)bIYjc?-Z+TwhdEvVszZp!k6`RAo}h#GDEhRuyF^SK#Eh3oeELx$76NS6in8Bc}O> zn;Aw!nHkd4G@+n^q22I_Fe@*0qmsjhH4Htg5gye6H@qBGs201}9(g^74>jTnt7Em| zd$x&f5Ee_XyMe)$)>Fx}3O_a)C;>5U3CVs0Ihw_3i(hKtXcd<&bzV2xINBjINTYfp zqf&xSj!oDsezgoscQdq@6(t-Fr;09gE9l|WcW<%bdf~UqV#yj9j$pf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or=%hJwD%xpJbXy5~(oDA04(o{FFh@H|8N6L-XU3Yg%{+9VQ$rU=H+saf(qtT= z8Xc8!D{haOmD84Ub-8lPs+@4lt1D)sjy~M3;V4Hx2E;X`xhjA=IPR4A^OJVma!jXl zGgaO;#BmJA#i++nhdJ)XJ>tBlhmDF2j~y(-eG>72WbXlvlXy@ZRgGv2agGGW7y{P3 zm6)9|iNLsHrV=JG6zQuS)iI6<4W~G4oE97Ep^9-NIVNRWJf2P`Ei*N2CTA^4WtwA3 zM6__o2Zv)?3d1*Ur_7{%Ru06AS#eV9U=NFBt(!d}e$_tn>pk-cYih<$r=~SLBYyP8 z*mGa%d0#XCTRPsxI~v}Vy}T!W(7$8LBI~PWABihIL-~XuEWY)Hh0b}#2Ny{bP(U() zO6ys&qO>#GJ;o~7=X7x4QCg)N2;wnX`BnfP#}j1bA%iC=N+$QwE{o=`LmOE|UVq&h z^#6|96LNH83%Tt(GDeGWBSo=9B|b@Vh2tRpr;@As{uc`(zELt7TX zFK}zHH;3COU~mQPWRl~q%Qykh+s%s9%Dv5=kSB-x52y{rY7XWatY#&o47(|3_G%!Z4G!0>n zzOM!B#S0X*h<#YXL0qKIN-{P?d{oe{^+Vr_wRwTPFADdK69 zPdTSWyn+kFY!j(>37J_%m{eWP zx?B=C^B+}n!FeLTpV+7&Hm;j}2>}FJ2zo2=(uN(wI83CpU#Efce~}gu)=SjUjT&&{ dbt>S(8_3e`CGVT`ypIpa(&_XeKE?_{{{X7_31k2O diff --git a/target/classes/br/com/movimentocodar/maquinadecafe/Pagamento.class b/target/classes/br/com/movimentocodar/maquinadecafe/Pagamento.class index a1cb95e3a3fe66f6857a18c5c3193e70774be95c..b53983d0d97522560f5c2eb99fd998ee8cc73864 100644 GIT binary patch delta 3485 zcmZ`*3wTt;75*oCckkWZn@zH?Avb{#Ac4&$O9DxwMx?=r8iXJsP_PP1vaTyhHYS@? zLAzpu6d$!ZRtZuCe8gI;2(qN8w7y!j58K+>T3fZXt=3wtRqG3(|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gllb3tI^9=WlRa}cy}4+e=6iF zX8w~le>5j66vK@`sE5=7(t?lQo&tE0wtR^N)j>k#6$Zv3hUZ}h@DWnSQPRaR+=bWh zFxwu*H%KaP-~hgfm-&h2yLb~n#J73&{vAfrTQU{jl9~9P)ZzQugEtdI{b-ci`D;?* z6`B&tIPNNa$9hm2^N{4-ZE^>(_5PH2KFzN56D#S zWAc0OPdrH(<{5|S!HO_`jceGuBB;uKFCG?CZxu|Xbve1RmabGqWnt-8n4n8_T4o27 z%4f)0{Aebh)%`ywJNaA7&m*6w;4jHTeDkP0CVTbsetmsPU%#ra&&YG^A7tO> Date: Tue, 16 Nov 2021 20:31:48 -0300 Subject: [PATCH 8/9] =?UTF-8?q?Atuali=C3=A7=C3=A3o=20do=20Desafio=20com=20?= =?UTF-8?q?testes=20e=20nova=20refatora=C3=A7=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/.gitignore | 8 +- ...Maven__org_mockito_mockito_all_1_10_19.xml | 13 - DesafioMaquinaDeCafe.iml | 14 +- pom.xml | 19 +- .../maquinadecafe/CafeScanner.java | 33 +- .../movimentocodar/maquinadecafe/Cupom.java | 15 +- .../movimentocodar/maquinadecafe/Cupons.java | 4 + .../movimentocodar/maquinadecafe/Main.java | 32 +- .../maquinadecafe/MaquinaDeCafe.java | 42 +-- .../maquinadecafe/Pagamento.java | 104 ++++--- .../maquinadecafe/ReservatorioDeAgua.java | 9 +- src/test/java/CupomTest.java | 44 +++ src/test/java/MaquinaDeCafeTest.java | 199 ++++++++++++ src/test/java/PagamentoTest.java | 180 +++++++++++ src/test/java/ReservatorioDeAguaTest.java | 40 +++ src/test/java/TestRunner.java | 24 ++ .../maquinadecafe/CafeScanner.class | Bin 6167 -> 5599 bytes .../movimentocodar/maquinadecafe/Cupom.class | Bin 4792 -> 4871 bytes .../movimentocodar/maquinadecafe/Cupons.class | Bin 3927 -> 4090 bytes .../movimentocodar/maquinadecafe/Main.class | Bin 3865 -> 2831 bytes .../maquinadecafe/MaquinaDeCafe.class | Bin 5123 -> 5696 bytes .../maquinadecafe/Pagamento.class | Bin 7263 -> 8036 bytes .../maquinadecafe/ReservatorioDeAgua.class | Bin 1653 -> 1800 bytes .../movimentocodar/maquinadecafe/teste.class | Bin 312 -> 0 bytes target/cupom.json | 294 +++++++++++++++--- target/test-classes/CupomTest.class | Bin 0 -> 2023 bytes target/test-classes/MaquinaDeCafeTest.class | Bin 0 -> 5831 bytes target/test-classes/PagamentoTest.class | Bin 0 -> 5899 bytes .../test-classes/ReservatorioDeAguaTest.class | Bin 0 -> 1828 bytes target/test-classes/TestRunner.class | Bin 0 -> 2241 bytes 30 files changed, 900 insertions(+), 174 deletions(-) delete mode 100644 .idea/libraries/Maven__org_mockito_mockito_all_1_10_19.xml create mode 100644 src/test/java/CupomTest.java create mode 100644 src/test/java/MaquinaDeCafeTest.java create mode 100644 src/test/java/PagamentoTest.java create mode 100644 src/test/java/ReservatorioDeAguaTest.java create mode 100644 src/test/java/TestRunner.java delete mode 100644 target/classes/br/com/movimentocodar/maquinadecafe/teste.class create mode 100644 target/test-classes/CupomTest.class create mode 100644 target/test-classes/MaquinaDeCafeTest.class create mode 100644 target/test-classes/PagamentoTest.class create mode 100644 target/test-classes/ReservatorioDeAguaTest.class create mode 100644 target/test-classes/TestRunner.class diff --git a/.idea/.gitignore b/.idea/.gitignore index 5360a32..4d526a1 100644 --- a/.idea/.gitignore +++ b/.idea/.gitignore @@ -2,9 +2,11 @@ /shelf/ /workspace.xml .idea -.idea/libraries/ +/libraries /out/ -src/main/java/br.com.movimentocodar.maquinadecafe/teste.java target/classes/ target/generated-sources/ -target/maven-status/ \ No newline at end of file +target/generated-test-sources/ +target/maven-status/ +target/test-classes/ +DesafioMaquinaDeCafe.iml \ No newline at end of file diff --git a/.idea/libraries/Maven__org_mockito_mockito_all_1_10_19.xml b/.idea/libraries/Maven__org_mockito_mockito_all_1_10_19.xml deleted file mode 100644 index c87b108..0000000 --- a/.idea/libraries/Maven__org_mockito_mockito_all_1_10_19.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/DesafioMaquinaDeCafe.iml b/DesafioMaquinaDeCafe.iml index 67cf504..9da9c46 100644 --- a/DesafioMaquinaDeCafe.iml +++ b/DesafioMaquinaDeCafe.iml @@ -18,6 +18,18 @@ - + + + + + + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index c10a84b..f240390 100644 --- a/pom.xml +++ b/pom.xml @@ -39,11 +39,24 @@ commons-codec 1.15 - + org.mockito - mockito-all - 1.10.19 + mockito-core + 3.12.4 + test + + + org.junit.jupiter + junit-jupiter + RELEASE + test + + + + com.github.stefanbirkner + system-rules + 1.19.0 test diff --git a/src/main/java/br/com/movimentocodar/maquinadecafe/CafeScanner.java b/src/main/java/br/com/movimentocodar/maquinadecafe/CafeScanner.java index a9eafd1..b9ea636 100644 --- a/src/main/java/br/com/movimentocodar/maquinadecafe/CafeScanner.java +++ b/src/main/java/br/com/movimentocodar/maquinadecafe/CafeScanner.java @@ -23,24 +23,19 @@ public void pedirConfirmacaoUsuario(){ do { System.out.println(this.mensagem); - entry = Scanner.nextLine(); + entry = Scanner.next(); checarSair(entry); } while(!entry.equals(this.respostaEsperada.toLowerCase())); } - public Bebida pedirSelecaoBebidaDoUsuario(MaquinaDeCafe MaquinaDeCafe){ + public void pedirSelecaoBebidaDoUsuario(MaquinaDeCafe MaquinaDeCafe){ String entry = ""; do { System.out.println(this.mensagem); - entry = Scanner.nextLine(); + entry = Scanner.next(); checarSair(entry); - } while(!bebidaEncontrada(entry, MaquinaDeCafe)); - - Bebida BebidaEscolhida = MaquinaDeCafe.getBebida(Integer.parseInt(entry)); - System.out.println("A bebida escolhida foi " + BebidaEscolhida.toString()); - - return BebidaEscolhida; + } while(!MaquinaDeCafe.encontrarBebidaPeloID(entry)); } public BigDecimal pedirSelecaoReaisAoUsuario(BigDecimal preco){ @@ -53,7 +48,7 @@ public BigDecimal pedirSelecaoReaisAoUsuario(BigDecimal preco){ valorAPagar = preco.subtract(valorPago); System.out.println(this.mensagem); System.out.println("Faltam " + Pagamento.moedaEmReais(valorAPagar)); - entry = Scanner.nextLine(); + entry = Scanner.next(); checarSair(entry); valorInserido = calcularValorInserido(entry); valorPago = valorPago.add(valorInserido); @@ -81,7 +76,7 @@ public Acucar pedirSelecaoAcucarDoUsuario(){ do { System.out.println(this.mensagem); - entry = Scanner.nextLine(); + entry = Scanner.next(); checarSair(entry); } while(!acucarEncontrada(entry)); @@ -111,7 +106,7 @@ public int pedirMetodoDePagamentoAoUsuario(){ do { System.out.println(this.mensagem); - entry = Scanner.nextLine(); + entry = Scanner.next(); checarSair(entry); } while(!metodoEncontrado(entry)); @@ -126,29 +121,21 @@ private boolean metodoEncontrado(String entry){ return false; } - private boolean bebidaEncontrada(String bebidaEscolhida, MaquinaDeCafe MaquinaDeCafe){ - try{ - MaquinaDeCafe.getBebida(Integer.parseInt(bebidaEscolhida)); - } catch (Exception ex) { - return false; - } - return true; - } private void checarSair(String entry){ if (entry.equals("sair")){ - System.out.println("Obrigado por utilizar a máquina de café 2021."); + System.out.println("Obrigado por utilizar a máquina de café 2021, o programa irá encerrar agora."); System.exit(-1); } } - public Cupom pedirCodigoCupom(Cupons cupons) { + public Cupom pedirCodigoCupomAoUsuario(Cupons cupons) { String entry = ""; do { System.out.println(this.mensagem); - entry = Scanner.nextLine(); + entry = Scanner.next(); checarSair(entry); } while(!cupomEncontrado(entry, cupons)); diff --git a/src/main/java/br/com/movimentocodar/maquinadecafe/Cupom.java b/src/main/java/br/com/movimentocodar/maquinadecafe/Cupom.java index 5065a01..da7c599 100644 --- a/src/main/java/br/com/movimentocodar/maquinadecafe/Cupom.java +++ b/src/main/java/br/com/movimentocodar/maquinadecafe/Cupom.java @@ -31,8 +31,8 @@ public Cupom(BigDecimal valor) { this.agora = new Timestamp(System.currentTimeMillis()); this.valor = valor; this.ativo = true; - gerarCodigo(); - calcularValidade(); + this.codigo = gerarCodigo(); + this.validade = calcularValidade(); cupomCriado(); } @@ -42,19 +42,19 @@ private void cupomCriado() { System.out.println("Válido apenas para compras na Máquina de Café até " + this.getValidade()); } - private void gerarCodigo(){ + private String gerarCodigo(){ LocalDateTime dataString = this.agora.toLocalDateTime(); long cupomNum = this.agora.getTime() * 3; Base32 base32 = new Base32(-1,null,false); String cupomStr = base32.encodeAsString(BigInteger.valueOf(cupomNum).toByteArray()); //cupomStr = DigestUtils.sha1Hex(cupomStr); - this.codigo = dataString.getMonth().toString().substring(0, 3) + Integer.toString(dataString.getYear()).substring(2, 4) + "-" + cupomStr.substring(0,9); + return dataString.getMonth().toString().substring(0, 3) + Integer.toString(dataString.getYear()).substring(2, 4) + "-" + cupomStr.substring(0,9); } - public void calcularValidade() { + public String calcularValidade() { DateTimeFormatter formatoData = DateTimeFormatter.ofPattern("dd/MM/yyyy"); LocalDateTime dataValidade = this.agora.toLocalDateTime(); - this.validade = dataValidade.plusMonths(3).format(formatoData); + return dataValidade.plusMonths(3).format(formatoData); } public void inativarCupom(){ @@ -87,4 +87,7 @@ public Boolean getAtivo() { return this.ativo; } + public void setValor(BigDecimal valor) { + this.valor = valor; + } } diff --git a/src/main/java/br/com/movimentocodar/maquinadecafe/Cupons.java b/src/main/java/br/com/movimentocodar/maquinadecafe/Cupons.java index 0b707d5..34b4d77 100644 --- a/src/main/java/br/com/movimentocodar/maquinadecafe/Cupons.java +++ b/src/main/java/br/com/movimentocodar/maquinadecafe/Cupons.java @@ -28,6 +28,10 @@ public Cupom encontrarCupom(String codigo){ return this.cupons.stream().filter(c -> c.getCodigo().equals(codigo)).findAny().get(); } + public String encontrarUltimoCupom(){ + return this.cupons.get(this.cupons.size()-1).getCodigo(); + } + public void lerJSON() throws IOException { byte[] mapData = Files.readAllBytes(Paths.get("target/cupom.json")); ObjectMapper mapper = new ObjectMapper(); diff --git a/src/main/java/br/com/movimentocodar/maquinadecafe/Main.java b/src/main/java/br/com/movimentocodar/maquinadecafe/Main.java index 6a4cff9..72d8daa 100644 --- a/src/main/java/br/com/movimentocodar/maquinadecafe/Main.java +++ b/src/main/java/br/com/movimentocodar/maquinadecafe/Main.java @@ -1,7 +1,5 @@ package br.com.movimentocodar.maquinadecafe; -import com.fasterxml.jackson.core.JsonParseException; - import java.io.IOException; /** @@ -16,13 +14,13 @@ */ public class Main { - public static void main(String[] args) throws JsonParseException, IOException { + public static void main(String[] args) throws IOException { ReservatorioDeAgua ReservatorioDeAgua = new ReservatorioDeAgua(); Cupons cupons = new Cupons(); inicializarMaquina(ReservatorioDeAgua, cupons); } - static void inicializarMaquina(ReservatorioDeAgua ReservatorioDeAgua, Cupons cupons) throws JsonParseException, IOException { + static void inicializarMaquina(ReservatorioDeAgua ReservatorioDeAgua, Cupons cupons) throws IOException { MaquinaDeCafe MaquinaDeCafe = new MaquinaDeCafe(ReservatorioDeAgua); if (MaquinaDeCafe.ReservatorioDeAgua.reservatorioDeAguaVazio()) { @@ -31,33 +29,25 @@ static void inicializarMaquina(ReservatorioDeAgua ReservatorioDeAgua, Cupons cup MaquinaDeCafe.ReservatorioDeAgua.completarReservatorioDeAgua(); } - MaquinaDeCafe.Menu(); + MaquinaDeCafe.menu(); Bebida BebidaEscolhida = MaquinaDeCafe.selecionarBebida(); - Pagamento Pagamento = new Pagamento(BebidaEscolhida.getPreco()); + Pagamento pagamento = new Pagamento(BebidaEscolhida.getPreco()); - if(Pagamento.Cortesia()){ + if(pagamento.cortesia()){ System.out.println("A bebida será de graça."); MaquinaDeCafe.liberarBebida(); - }else{ - System.out.println("O total é de " + Pagamento.moedaEmReais() + "."); - - Boolean sucesso; - do { - CafeScanner selecionarMetodoDePagamento = new CafeScanner("Digite 1 para pagamento em dinheiro, 2 para pagamento em cartão de débito e 3 para utilizar cupom."); - int MetodoDePagamento = selecionarMetodoDePagamento.pedirMetodoDePagamentoAoUsuario(); - sucesso = Pagamento.executarCobranca(MetodoDePagamento, cupons); - }while(!sucesso); - - MaquinaDeCafe.determinarNivelDeAcucar(); - MaquinaDeCafe.liberarBebida(); + }else { + if(pagamento.executarCobranca(cupons)) { + MaquinaDeCafe.determinarNivelDeAcucar(); + MaquinaDeCafe.liberarBebida(); + } } finalizacao(ReservatorioDeAgua, cupons); } - private static void finalizacao(ReservatorioDeAgua ReservatorioDeAgua, Cupons cupons) throws JsonParseException, IOException{ - System.out.println("Retire a bebida e obrigado por utilizar a máquina de café."); + private static void finalizacao(ReservatorioDeAgua ReservatorioDeAgua, Cupons cupons) throws IOException{ CafeScanner finalizar = new CafeScanner("Digite 'sair' para sair ou 'iniciar' para comprar outra bebida.", "iniciar"); finalizar.pedirConfirmacaoUsuario(); inicializarMaquina(ReservatorioDeAgua, cupons); diff --git a/src/main/java/br/com/movimentocodar/maquinadecafe/MaquinaDeCafe.java b/src/main/java/br/com/movimentocodar/maquinadecafe/MaquinaDeCafe.java index 7810d1f..2421d3a 100644 --- a/src/main/java/br/com/movimentocodar/maquinadecafe/MaquinaDeCafe.java +++ b/src/main/java/br/com/movimentocodar/maquinadecafe/MaquinaDeCafe.java @@ -32,51 +32,53 @@ public void BoasVindas(){ System.out.println("Para sair, digite 'sair' a qualquer momento."); } - public Bebida getBebida(int id){ - Bebida bebida = new Bebida(); + public boolean encontrarBebidaPeloID(String entry){ try{ - bebida = menu.get(id); - } catch (ArrayIndexOutOfBoundsException ex){ - throw ex; + this.BebidaEscolhida = menu.get(Integer.parseInt(entry)); + assert(this.BebidaEscolhida != null): "Bebida encontrada " + this.BebidaEscolhida.toString(); + } catch (Exception ex) { + return false; } - return bebida; + + return true; } - public void Menu(){ + public void menu(){ for (Bebida bebida : menu) { System.out.println(bebida.getId() + " - " + bebida.toString() + " - " + (bebida.getPreco().compareTo(BigDecimal.ZERO) == 0? "grátis" : Pagamento.moedaEmReais(bebida.getPreco()))); } } public void liberarBebida(){ - this.ReservatorioDeAgua.liberarAguaParaUmaBebida(); - - if (NivelAcucarEscolhido == null){ - NivelAcucarEscolhido = Acucar.NIVEL_0; + try { + this.ReservatorioDeAgua.liberarAguaParaUmaBebida(); + + if (NivelAcucarEscolhido == null) { + NivelAcucarEscolhido = Acucar.NIVEL_0; + } + this.BebidaEscolhida.receita.preparar(NivelAcucarEscolhido); + System.out.println("Retire a bebida e obrigado por utilizar a máquina de café."); + } catch (Exception ex){ + System.out.println("Necessário escolher uma bebida primeiro e ter reservatórios de água cheios"); } - - this.BebidaEscolhida.receita.preparar(NivelAcucarEscolhido); } public Bebida selecionarBebida(){ CafeScanner selecionarBebida = new CafeScanner("Digite o número da bebida escolhida"); - this.BebidaEscolhida = selecionarBebida.pedirSelecaoBebidaDoUsuario(this); + selecionarBebida.pedirSelecaoBebidaDoUsuario(this); + System.out.println("A bebida escolhida foi " + this.BebidaEscolhida.toString()); return this.BebidaEscolhida; } - public void determinarNivelDeAcucar(){ + public Acucar determinarNivelDeAcucar(){ System.out.println("--Favor escolher um nível de açúcar para sua bebida--"); Acucar NiveisDeAcucar[] = Acucar.values(); for (Acucar nivel : NiveisDeAcucar) { nivel.imprimirNiveisDeAcucar(); } CafeScanner nivelDeAcucar = new CafeScanner("Digite o número do nível de açúcar escolhido."); - this.NivelAcucarEscolhido = nivelDeAcucar.pedirSelecaoAcucarDoUsuario(); + return this.NivelAcucarEscolhido = nivelDeAcucar.pedirSelecaoAcucarDoUsuario(); } - - - - } diff --git a/src/main/java/br/com/movimentocodar/maquinadecafe/Pagamento.java b/src/main/java/br/com/movimentocodar/maquinadecafe/Pagamento.java index a4bda7e..f76cb4e 100644 --- a/src/main/java/br/com/movimentocodar/maquinadecafe/Pagamento.java +++ b/src/main/java/br/com/movimentocodar/maquinadecafe/Pagamento.java @@ -13,7 +13,7 @@ public Pagamento(BigDecimal valor){ this.valor = valor; } - public boolean Cortesia(){ + public boolean cortesia(){ if (this.valor.compareTo(BigDecimal.ZERO) == 0){ return true; } @@ -29,7 +29,21 @@ public static String moedaEmReais(BigDecimal valor) { return "R$ " + valor.setScale(2, RoundingMode.HALF_EVEN); } - public boolean executarCobranca(int MetodoDePagamento, Cupons cupons) throws IOException { + public boolean executarCobranca(Cupons cupons) throws IOException { + System.out.println("O total é de " + this.moedaEmReais() + "."); + Boolean sucesso; + + do { + CafeScanner selecionarMetodoDePagamento = new CafeScanner("Digite 1 para pagamento em dinheiro, 2 para pagamento em cartão de débito e 3 para utilizar cupom."); + int MetodoDePagamento = selecionarMetodoDePagamento.pedirMetodoDePagamentoAoUsuario(); + sucesso = this.metodosDePagamento(MetodoDePagamento, cupons); + } while (!sucesso); + + return sucesso; + } + + + public boolean metodosDePagamento(int MetodoDePagamento, Cupons cupons) throws IOException { this.metodoDePagamento = MetodoDePagamento; cupons.lerJSON(); // 1: Pagamento em dinheiro @@ -43,20 +57,8 @@ public boolean executarCobranca(int MetodoDePagamento, Cupons cupons) throws IOE int sugestaoDePagamentoComDinheiro = selecionarSugestaoDePagamentoComDinheiro.pedirMetodoDePagamentoAoUsuario(); if(sugestaoDePagamentoComDinheiro == 3){ - NotasEMoedas Reais[] = NotasEMoedas.values(); - for (NotasEMoedas real: Reais) { - real.imprimir(); - } - - CafeScanner selecionarReais = new CafeScanner("Favor digitar o número da nota ou moeda inserida. Atenção: essa máquina não devolve troco, apenas cupom válido por 3 meses."); - BigDecimal troco = selecionarReais.pedirSelecaoReaisAoUsuario(this.valor); - - if(troco.compareTo(BigDecimal.ZERO) > 0){ - Cupom novoCupom = new Cupom(troco); - cupons.addNovoCupom(novoCupom); - } + escolherQualquerReal(cupons); return true; - } else { System.out.println("Pagamento aceito!"); return true; @@ -67,37 +69,59 @@ public boolean executarCobranca(int MetodoDePagamento, Cupons cupons) throws IOE System.out.println("Transação aprovada"); return true; }else if(MetodoDePagamento == 3) { - CafeScanner procurarCupom = new CafeScanner("Favor digitar o código do cupom."); - Cupom cupom = procurarCupom.pedirCodigoCupom(cupons); - if(cupom.getAtivo()) { - if (cupom.checaValidade()) { - cupom.inativarCupom(); - BigDecimal troco = this.valor.subtract(cupom.getValor()); - if (troco.compareTo(BigDecimal.ZERO) < 0) { - troco = cupom.getValor().subtract(this.valor); - Cupom novoCupom = new Cupom(troco); - cupons.addNovoCupom(novoCupom); - return true; - } else if (troco.compareTo(BigDecimal.ZERO) == 0) { - System.out.println("Cupom aceito com sucesso!"); - cupons.gravarJSON(); - return true; - } else { - System.out.println("Cupom aceito com sucesso. Faltam " + moedaEmReais(troco) + "."); - this.valor = troco; - } - } else { - System.out.println("Cupom expirado! Favor escolher utilizar outro cupom ou escolher outro método de pagamento."); - } - } else { - System.out.println("Cupom expirado! Utilize um código ativo e dentro da validade, ou outro método de pagamento."); - System.out.println("Caso tenha tentado utilizar o cupom com troco de outro cupom, verifique se foi gerado um novo código."); + if(pagamentoConcluidoComCupom(cupons)){ + cupons.gravarJSON(); + return true; } } cupons.gravarJSON(); return false; } + private boolean pagamentoConcluidoComCupom(Cupons cupons) throws IOException { + CafeScanner procurarCupom = new CafeScanner("Favor digitar o código do cupom."); + Cupom cupom = procurarCupom.pedirCodigoCupomAoUsuario(cupons); + if(cupom.getAtivo()) { + if (cupom.checaValidade()) { + cupom.inativarCupom(); + BigDecimal troco = this.valor.subtract(cupom.getValor()); + if (troco.compareTo(BigDecimal.ZERO) < 0) { + troco = cupom.getValor().subtract(this.valor); + Cupom novoCupom = new Cupom(troco); + cupons.addNovoCupom(novoCupom); + return true; + } else if (troco.compareTo(BigDecimal.ZERO) == 0) { + System.out.println("Cupom aceito com sucesso!"); + return true; + } else { + System.out.println("Cupom aceito com sucesso. Faltam " + moedaEmReais(troco) + "."); + this.valor = troco; + } + } else { + System.out.println("Cupom expirado! Favor escolher utilizar outro cupom ou escolher outro método de pagamento."); + } + } else { + System.out.println("Cupom expirado! Utilize um código ativo e dentro da validade, ou outro método de pagamento."); + System.out.println("Caso tenha tentado utilizar o cupom com troco de outro cupom, verifique se foi gerado um novo código."); + } + return false; + } + + private void escolherQualquerReal(Cupons cupons) throws IOException { + NotasEMoedas Reais[] = NotasEMoedas.values(); + for (NotasEMoedas real: Reais) { + real.imprimir(); + } + + CafeScanner selecionarReais = new CafeScanner("Favor digitar o número da nota ou moeda inserida. Atenção: essa máquina não devolve troco, apenas cupom válido por 3 meses."); + BigDecimal troco = selecionarReais.pedirSelecaoReaisAoUsuario(this.valor); + + if(troco.compareTo(BigDecimal.ZERO) > 0){ + Cupom novoCupom = new Cupom(troco); + cupons.addNovoCupom(novoCupom); + } + } + public BigDecimal calcularQuantidadeDeDinheiro(BigDecimal valor, NotasEMoedas Real, BigDecimal contagem, boolean SegundaSugestao){ int quantidadeDeREAL; Real.setQuantidade(0); diff --git a/src/main/java/br/com/movimentocodar/maquinadecafe/ReservatorioDeAgua.java b/src/main/java/br/com/movimentocodar/maquinadecafe/ReservatorioDeAgua.java index 00ef16c..b168eb7 100644 --- a/src/main/java/br/com/movimentocodar/maquinadecafe/ReservatorioDeAgua.java +++ b/src/main/java/br/com/movimentocodar/maquinadecafe/ReservatorioDeAgua.java @@ -24,7 +24,12 @@ public void completarReservatorioDeAgua(){ System.out.println("Reservatório de água completo, " + msgReservatorioDeAgua); } - public void liberarAguaParaUmaBebida(){ - this.quantidadeDeAgua -= 50; + public void liberarAguaParaUmaBebida() throws Exception { + if(this.quantidadeDeAgua >= 50){ + this.quantidadeDeAgua -= 50; + }else { + System.out.println("Quantidade de água abaixo do esperado"); + throw new Exception(); + } } } diff --git a/src/test/java/CupomTest.java b/src/test/java/CupomTest.java new file mode 100644 index 0000000..e0d8bb5 --- /dev/null +++ b/src/test/java/CupomTest.java @@ -0,0 +1,44 @@ +import br.com.movimentocodar.maquinadecafe.Cupom; +import br.com.movimentocodar.maquinadecafe.Cupons; +import org.junit.Assert; +import org.junit.Test; +import org.mockito.Mockito; + +import java.io.IOException; +import java.math.BigDecimal; + +public class CupomTest { + @Test + public void deveriaInativarCupom() throws IOException { + Cupons cupons = new Cupons(); + + BigDecimal valor = BigDecimal.valueOf(1.00); + Cupom novoCupom = new Cupom(valor); + cupons.addNovoCupom(novoCupom); + cupons.encontrarCupom(cupons.encontrarUltimoCupom()).inativarCupom(); + + Assert.assertFalse(cupons.encontrarCupom(cupons.encontrarUltimoCupom()).getAtivo()); + } + + @Test + public void deveriaChecarValidade() throws IOException { + Cupons cupons = new Cupons(); + + BigDecimal valor = BigDecimal.valueOf(1.00); + Cupom novoCupom = new Cupom(valor); + cupons.addNovoCupom(novoCupom); + + Assert.assertTrue(cupons.encontrarCupom(cupons.encontrarUltimoCupom()).checaValidade()); + } + + @Test + public void deveriaChecarValidadeVencido() { + BigDecimal valor = BigDecimal.valueOf(1.00); + + final Cupom novoCupom = Mockito.mock(Cupom.class); + novoCupom.setValor(valor); + Mockito.when(novoCupom.calcularValidade()).thenReturn("07/11/2021"); + + Assert.assertFalse(novoCupom.checaValidade()); + } +} diff --git a/src/test/java/MaquinaDeCafeTest.java b/src/test/java/MaquinaDeCafeTest.java new file mode 100644 index 0000000..bff4583 --- /dev/null +++ b/src/test/java/MaquinaDeCafeTest.java @@ -0,0 +1,199 @@ +import br.com.movimentocodar.maquinadecafe.*; +import org.junit.Assert; +import org.junit.Rule; +import org.junit.Test; +import org.junit.contrib.java.lang.system.TextFromStandardInputStream; + +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; +import java.util.NoSuchElementException; + +import static org.junit.contrib.java.lang.system.TextFromStandardInputStream.emptyStandardInputStream; + +public class MaquinaDeCafeTest { + @Rule + public final TextFromStandardInputStream systemInMock + = emptyStandardInputStream(); + + @Test + public void deveriaLiberarCafeComAcucarNivel1() { + final ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outputStreamCaptor)); + + final String strBebida = "0"; + final String nivelAcucar = "1"; + + Bebida cafe = new Cafe(); + ReservatorioDeAgua reservatorioDeAgua = new ReservatorioDeAgua(); + MaquinaDeCafe maquinaDeCafe = new MaquinaDeCafe(reservatorioDeAgua); + + systemInMock.provideLines(strBebida); + Assert.assertEquals(maquinaDeCafe.selecionarBebida().getId(), cafe.getId()); + systemInMock.provideLines(nivelAcucar); + Assert.assertEquals(maquinaDeCafe.determinarNivelDeAcucar(), Acucar.NIVEL_1); + maquinaDeCafe.liberarBebida(); + Assert.assertTrue(outputStreamCaptor.toString().trim().contains("Retire a bebida e obrigado por utilizar a máquina de café.")); + } + + @Test + public void deveriaLiberarCafeComAcucarIndefinido() { + final ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outputStreamCaptor)); + + final String strBebida = "0"; + + Bebida cafe = new Cafe(); + ReservatorioDeAgua reservatorioDeAgua = new ReservatorioDeAgua(); + MaquinaDeCafe maquinaDeCafe = new MaquinaDeCafe(reservatorioDeAgua); + + systemInMock.provideLines(strBebida); + Assert.assertEquals(maquinaDeCafe.selecionarBebida().getId(), cafe.getId()); + maquinaDeCafe.liberarBebida(); + Assert.assertTrue(outputStreamCaptor.toString().trim().contains("Retire a bebida e obrigado por utilizar a máquina de café.")); + } + + @Test + public void deveriaLiberarCafeComLeiteComAcucarNivel3() { + final ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outputStreamCaptor)); + + final String strBebida = "1"; + final String nivelAcucar = "3"; + + Bebida cafeComLeite = new CafeComLeite(); + ReservatorioDeAgua reservatorioDeAgua = new ReservatorioDeAgua(); + MaquinaDeCafe maquinaDeCafe = new MaquinaDeCafe(reservatorioDeAgua); + + systemInMock.provideLines(strBebida); + Assert.assertEquals(maquinaDeCafe.selecionarBebida().getId(), cafeComLeite.getId()); + systemInMock.provideLines(nivelAcucar); + Assert.assertEquals(maquinaDeCafe.determinarNivelDeAcucar(), Acucar.NIVEL_3); + maquinaDeCafe.liberarBebida(); + Assert.assertTrue(outputStreamCaptor.toString().trim().contains("Retire a bebida e obrigado por utilizar a máquina de café.")); + } + + @Test + public void deveriaLiberarChaDeLimaoComAcucarNivel5() { + final ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outputStreamCaptor)); + + final String strBebida = "3"; + final String nivelAcucar = "5"; + + Bebida cha = new ChaDeLimao(); + ReservatorioDeAgua reservatorioDeAgua = new ReservatorioDeAgua(); + MaquinaDeCafe maquinaDeCafe = new MaquinaDeCafe(reservatorioDeAgua); + + systemInMock.provideLines(strBebida); + Assert.assertEquals(maquinaDeCafe.selecionarBebida().getId(), cha.getId()); + systemInMock.provideLines(nivelAcucar); + Assert.assertEquals(maquinaDeCafe.determinarNivelDeAcucar(), Acucar.NIVEL_5); + maquinaDeCafe.liberarBebida(); + Assert.assertTrue(outputStreamCaptor.toString().trim().contains("Retire a bebida e obrigado por utilizar a máquina de café.")); + } + + @Test + public void deveriaLiberarAguaQuenteEIgnorarAcucar() { + final ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outputStreamCaptor)); + + final String strBebida = "4"; + final String nivelAcucar = "2"; + + Bebida aguaQuente = new AguaQuente(); + ReservatorioDeAgua reservatorioDeAgua = new ReservatorioDeAgua(); + MaquinaDeCafe maquinaDeCafe = new MaquinaDeCafe(reservatorioDeAgua); + + systemInMock.provideLines(strBebida); + Assert.assertEquals(maquinaDeCafe.selecionarBebida().getId(), aguaQuente.getId()); + systemInMock.provideLines(nivelAcucar); + Assert.assertEquals(maquinaDeCafe.determinarNivelDeAcucar(), Acucar.NIVEL_2); + maquinaDeCafe.liberarBebida(); + Assert.assertTrue(outputStreamCaptor.toString().trim().contains("Retire a bebida e obrigado por utilizar a máquina de café.")); + } + + @Test + public void determinarAcucarNivel0() { + final ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outputStreamCaptor)); + + final String nivelAcucar = "0"; + + ReservatorioDeAgua reservatorioDeAgua = new ReservatorioDeAgua(); + MaquinaDeCafe maquinaDeCafe = new MaquinaDeCafe(reservatorioDeAgua); + + systemInMock.provideLines(nivelAcucar); + Assert.assertEquals(maquinaDeCafe.determinarNivelDeAcucar(), Acucar.NIVEL_0); + } + + @Test + public void determinarAcucarNivel2() { + final ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outputStreamCaptor)); + + final String nivelAcucar = "2"; + + ReservatorioDeAgua reservatorioDeAgua = new ReservatorioDeAgua(); + MaquinaDeCafe maquinaDeCafe = new MaquinaDeCafe(reservatorioDeAgua); + + systemInMock.provideLines(nivelAcucar); + Assert.assertEquals(maquinaDeCafe.determinarNivelDeAcucar(), Acucar.NIVEL_2); + } + + @Test + public void determinarAcucarNivel4() { + final ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outputStreamCaptor)); + + final String nivelAcucar = "4"; + + ReservatorioDeAgua reservatorioDeAgua = new ReservatorioDeAgua(); + MaquinaDeCafe maquinaDeCafe = new MaquinaDeCafe(reservatorioDeAgua); + + systemInMock.provideLines(nivelAcucar); + Assert.assertEquals(maquinaDeCafe.determinarNivelDeAcucar(), Acucar.NIVEL_4); + } + + @Test + public void deveriaLiberarCapuccinoEAcucarNaoDefinido() { + final ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outputStreamCaptor)); + + final String strBebida = "2"; + + Bebida capuccino = new Cappuccino(); + ReservatorioDeAgua reservatorioDeAgua = new ReservatorioDeAgua(); + MaquinaDeCafe maquinaDeCafe = new MaquinaDeCafe(reservatorioDeAgua); + + systemInMock.provideLines(strBebida); + Assert.assertEquals(maquinaDeCafe.selecionarBebida().getId(), capuccino.getId()); + maquinaDeCafe.liberarBebida(); + Assert.assertTrue(outputStreamCaptor.toString().trim().contains("Retire a bebida e obrigado por utilizar a máquina de café.")); + } + + @Test + public void deveriaRetornarMenu() { + final ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outputStreamCaptor)); + + ReservatorioDeAgua reservatorioDeAgua = new ReservatorioDeAgua(); + MaquinaDeCafe maquinaDeCafe = new MaquinaDeCafe(reservatorioDeAgua); + + maquinaDeCafe.menu(); + Assert.assertTrue(outputStreamCaptor.toString().trim().contains("0 - Café")); + } + + + @Test(expected = NoSuchElementException.class) + public void deveriaLiberarFinalizarPrograma() { + final String strBebida = "testandobebidaquenãoexiste"; + + Bebida bebida = new Bebida(); + ReservatorioDeAgua reservatorioDeAgua = new ReservatorioDeAgua(); + MaquinaDeCafe maquinaDeCafe = new MaquinaDeCafe(reservatorioDeAgua); + + systemInMock.provideLines(strBebida); + + Assert.assertEquals(maquinaDeCafe.selecionarBebida().getId(), bebida.getId()); + } +} diff --git a/src/test/java/PagamentoTest.java b/src/test/java/PagamentoTest.java new file mode 100644 index 0000000..70edd58 --- /dev/null +++ b/src/test/java/PagamentoTest.java @@ -0,0 +1,180 @@ +import br.com.movimentocodar.maquinadecafe.*; +import org.junit.Assert; +import org.junit.Rule; +import org.junit.Test; +import org.junit.contrib.java.lang.system.TextFromStandardInputStream; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.PrintStream; +import java.math.BigDecimal; + +import static org.junit.contrib.java.lang.system.TextFromStandardInputStream.emptyStandardInputStream; + +public class PagamentoTest { + @Rule + public final TextFromStandardInputStream systemInMock + = emptyStandardInputStream(); + + @Test + public void deveriaRetornarCortesia() { + Bebida aguaQuente = new AguaQuente(); + ReservatorioDeAgua reservatorioDeAgua = new ReservatorioDeAgua(); + MaquinaDeCafe maquinaDeCafe = new MaquinaDeCafe(reservatorioDeAgua); + + Assert.assertEquals(maquinaDeCafe.selecionarBebida().getId(), aguaQuente.getId()); + Pagamento pagamento = new Pagamento(aguaQuente.getPreco()); + + Assert.assertTrue(pagamento.cortesia()); + } + + @Test + public void naoDeveriaRetornarCortesia() { + Bebida cafe = new Cafe(); + ReservatorioDeAgua reservatorioDeAgua = new ReservatorioDeAgua(); + MaquinaDeCafe maquinaDeCafe = new MaquinaDeCafe(reservatorioDeAgua); + + Assert.assertEquals(maquinaDeCafe.selecionarBebida().getId(), cafe.getId()); + Pagamento pagamento = new Pagamento(cafe.getPreco()); + + Assert.assertFalse(pagamento.cortesia()); + } + + + @Test + public void deveriaPagarComDinheiroAceitandoSugestao1() throws IOException { + final ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outputStreamCaptor)); + + final String strChaDeLimao = "3"; + final String pgtoDinheiro = "1"; + final String aceitarSugestaoDinheiro1 = "1"; + + ReservatorioDeAgua reservatorioDeAgua = new ReservatorioDeAgua(); + MaquinaDeCafe maquinaDeCafe = new MaquinaDeCafe(reservatorioDeAgua); + Cupons cupons = new Cupons(); + + systemInMock.provideLines(strChaDeLimao); + Pagamento pagamento = new Pagamento(maquinaDeCafe.selecionarBebida().getPreco()); + + systemInMock.provideLines(pgtoDinheiro, aceitarSugestaoDinheiro1); + Assert.assertTrue(pagamento.executarCobranca(cupons)); + } + + @Test + public void deveriaPagarComDinheiroAceitandoSugestao2() throws IOException { + final ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outputStreamCaptor)); + + final String strCafe = "0"; + final String pgtoDinheiro = "1"; + final String aceitarSugestaoDinheiro2 = "2"; + + ReservatorioDeAgua reservatorioDeAgua = new ReservatorioDeAgua(); + MaquinaDeCafe maquinaDeCafe = new MaquinaDeCafe(reservatorioDeAgua); + Cupons cupons = new Cupons(); + + systemInMock.provideLines(strCafe); + Pagamento pagamento = new Pagamento(maquinaDeCafe.selecionarBebida().getPreco()); + + systemInMock.provideLines(pgtoDinheiro, aceitarSugestaoDinheiro2); + Assert.assertTrue(pagamento.executarCobranca(cupons)); + } + + + @Test + public void deveriaPagarComDinheiroEscolherReaisEUsarCupomAteAcabar() throws IOException { + final ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outputStreamCaptor)); + + final String strCafe = "0"; + final String strCapuccino = "2"; + final String strChaDeLimao = "3"; + final String pgtoDinheiro = "1"; + final String pgtoCupom= "3"; + final String escolherQualquerNotaouMoeda = "3"; + final String IDdaNotaDe5 = "5"; + final String IDdaMoedaDe1 = "8"; + + ReservatorioDeAgua reservatorioDeAgua = new ReservatorioDeAgua(); + MaquinaDeCafe maquinaDeCafe = new MaquinaDeCafe(reservatorioDeAgua); + Cupons cupons = new Cupons(); + + systemInMock.provideLines(strCafe); + Pagamento pagamento = new Pagamento(maquinaDeCafe.selecionarBebida().getPreco()); + + systemInMock.provideLines(pgtoDinheiro, escolherQualquerNotaouMoeda, IDdaNotaDe5); + Assert.assertTrue(pagamento.executarCobranca(cupons)); + + systemInMock.provideLines(strCapuccino); + Pagamento pagamento2 = new Pagamento(maquinaDeCafe.selecionarBebida().getPreco()); + + systemInMock.provideLines(pgtoCupom, cupons.encontrarUltimoCupom()); + Assert.assertTrue(pagamento2.executarCobranca(cupons)); + + systemInMock.provideLines(strCapuccino); + Pagamento pagamento3 = new Pagamento(maquinaDeCafe.selecionarBebida().getPreco()); + + systemInMock.provideLines(pgtoCupom, cupons.encontrarUltimoCupom()); + Assert.assertTrue(pagamento3.executarCobranca(cupons)); + + systemInMock.provideLines(strChaDeLimao); + Pagamento pagamento4 = new Pagamento(maquinaDeCafe.selecionarBebida().getPreco()); + + systemInMock.provideLines(pgtoCupom, cupons.encontrarUltimoCupom()); + Assert.assertTrue(pagamento4.executarCobranca(cupons)); + + systemInMock.provideLines(strCapuccino); + Pagamento pagamento5 = new Pagamento(maquinaDeCafe.selecionarBebida().getPreco()); + + systemInMock.provideLines(pgtoCupom, cupons.encontrarUltimoCupom(), pgtoDinheiro, escolherQualquerNotaouMoeda, IDdaMoedaDe1); + Assert.assertTrue(pagamento5.executarCobranca(cupons)); + + Assert.assertFalse(cupons.encontrarCupom(cupons.encontrarUltimoCupom()).getAtivo()); + } + + @Test + public void deveriaPagarComCartaoDeDebito() throws IOException { + final ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outputStreamCaptor)); + + final String strCafe = "0"; + final String pgtoCartaoDeDebito = "2"; + final String cartaoInserido= "1"; + + ReservatorioDeAgua reservatorioDeAgua = new ReservatorioDeAgua(); + MaquinaDeCafe maquinaDeCafe = new MaquinaDeCafe(reservatorioDeAgua); + Cupons cupons = new Cupons(); + + systemInMock.provideLines(strCafe); + Pagamento pagamento = new Pagamento(maquinaDeCafe.selecionarBebida().getPreco()); + + systemInMock.provideLines(pgtoCartaoDeDebito, cartaoInserido); + Assert.assertTrue(pagamento.executarCobranca(cupons)); + } + + @Test + public void deveriaPagarComCupom() throws IOException { + final ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outputStreamCaptor)); + + final String strCafe = "0"; + final String pgtoCupom= "3"; + + ReservatorioDeAgua reservatorioDeAgua = new ReservatorioDeAgua(); + MaquinaDeCafe maquinaDeCafe = new MaquinaDeCafe(reservatorioDeAgua); + Cupons cupons = new Cupons(); + + BigDecimal valor = BigDecimal.valueOf(2.00); + Cupom novoCupom = new Cupom(valor); + cupons.addNovoCupom(novoCupom); + + systemInMock.provideLines(strCafe); + Pagamento pagamento = new Pagamento(maquinaDeCafe.selecionarBebida().getPreco()); + + systemInMock.provideLines(pgtoCupom, cupons.encontrarUltimoCupom()); + Assert.assertTrue(pagamento.executarCobranca(cupons)); + + Assert.assertTrue(cupons.encontrarCupom(cupons.encontrarUltimoCupom()).getAtivo()); + } +} diff --git a/src/test/java/ReservatorioDeAguaTest.java b/src/test/java/ReservatorioDeAguaTest.java new file mode 100644 index 0000000..2544df7 --- /dev/null +++ b/src/test/java/ReservatorioDeAguaTest.java @@ -0,0 +1,40 @@ +import br.com.movimentocodar.maquinadecafe.*; +import org.junit.Assert; +import org.junit.Test; + +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; + +public class ReservatorioDeAguaTest { + + @Test(expected = Exception.class) + public void deveriaRetornarReservatorioDeAguaVazio() throws Exception { + final ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outputStreamCaptor)); + ReservatorioDeAgua reservatorioDeAgua = new ReservatorioDeAgua(); + for(int i = 0; i<21; i++){ + reservatorioDeAgua.liberarAguaParaUmaBebida(); + } + Assert.assertTrue(outputStreamCaptor.toString().trim().contains("Quantidade de água abaixo do esperado")); + } + + @Test + public void deveriaCompletarReservatorioDeAgua() throws Exception { + final ByteArrayOutputStream outputStreamCaptor = new ByteArrayOutputStream(); + System.setOut(new PrintStream(outputStreamCaptor)); + ReservatorioDeAgua reservatorioDeAgua = new ReservatorioDeAgua(); + for(int i = 0; i<20; i++){ + reservatorioDeAgua.liberarAguaParaUmaBebida(); + } + reservatorioDeAgua.completarReservatorioDeAgua(); + Assert.assertTrue(outputStreamCaptor.toString().trim().contains("Reservatório de água completo")); + + reservatorioDeAgua.liberarAguaParaUmaBebida(); + } + + @Test + public void deveriaLiberarAguaParaUmaBebida() throws Exception { + ReservatorioDeAgua reservatorioDeAgua = new ReservatorioDeAgua(); + reservatorioDeAgua.liberarAguaParaUmaBebida(); + } +} diff --git a/src/test/java/TestRunner.java b/src/test/java/TestRunner.java new file mode 100644 index 0000000..15f705b --- /dev/null +++ b/src/test/java/TestRunner.java @@ -0,0 +1,24 @@ +import org.junit.runner.JUnitCore; +import org.junit.runner.Result; +import org.junit.runner.notification.Failure; + +import java.util.ArrayList; + +public class TestRunner { + public static void main(String[] args) { + ArrayList resultList = new ArrayList(); + resultList.add(JUnitCore.runClasses(MaquinaDeCafeTest.class)); + resultList.add(JUnitCore.runClasses(CupomTest.class)); + resultList.add(JUnitCore.runClasses(PagamentoTest.class)); + resultList.add(JUnitCore.runClasses(ReservatorioDeAguaTest.class)); + + for (Result result: resultList) { + for (Failure failure : result.getFailures()) { + System.out.println(result.getClass().getName() + " - " + failure.toString()); + } + + System.out.println(result.getClass().getName() + " - " + result.wasSuccessful()); + } + + } +} diff --git a/target/classes/br/com/movimentocodar/maquinadecafe/CafeScanner.class b/target/classes/br/com/movimentocodar/maquinadecafe/CafeScanner.class index 9d6ed8bc47cedd38d94daa45d59f007d35e195e0..6a261c2e07c40368bbf36ae2cf55e017ad75a5f5 100644 GIT binary patch delta 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*+3F6q@ZZ8pX28kQp^nGUxnhZ81! z9JVn>l;5+a zNrnmzg6cOQZsNenF#J&6?Hf zYOAXJap|>-C-5RdaRkv%I?<$I^kOP$t-<5(`=CfDN@w}W}$@2o!5}8s}C7UO09$PC^ ztvFx1qz7twk(VSdcUf>F$g{Gto$L%WxWA)uftwcC*0D&mKhN&Y;Kegk*Duo69|{Kc z(684IM!FG=eU0c(~jjhJ}2d?L}WyoQ!r7FDa7_WDD4eNb`#gh zzk7p>U86{ja3f7L&>}m#`8$~O3ZRtNcwJOAiLN(zQ&ysG$*IX!-r{X3WfQ)`yW+Hp zYaP#S$8#mF%fhV7ycqNu42XAoda~Z-3n(+~u@#ajq24YO_K*|>a~yrJKF6cyWao0) t@c&ULat1&E6!E?@N^U-I@E`J#eC+}LSp0v%Ilg92BBn&X;XFAi{{}3|>gWIf diff --git a/target/classes/br/com/movimentocodar/maquinadecafe/Main.class b/target/classes/br/com/movimentocodar/maquinadecafe/Main.class index 05964ff7a4e24399357877cdad58adb589c6f643..ac3e8b649ca2d1781f688750fbc57f60b15b9628 100644 GIT binary patch delta 657 zcmY+BOHUI~7>1wIi_;Dh(u=KH)FMitEukh=5~DGoE?jyEA}GpGT5W|6R;q}%ts7&^ ztXTRJhzSx+jB7Xk3s)}u0cw1wH4$f$?_9p`yyyAevw8S+*8cMQ!zbVj&$sMm*sQ$k zg!dU!^}OaD$tE(aJ>)pcC${LNvXz@K}OOp^a#UKp{>WWUUfIHmPDo%r@s+Rn^Gcq64rX(4} zn8*|CC8Iw$H%M49%RQDg#srXKKw1f@uh5c)r~LqDRoSEzqzWdly{Iyt|J}LvB6A>8 z+GctaXKb6<8HFpw(hlI0^X*ih0+B!x}we+9f4N#x(|7z!bwT2^H|Uus!S37 zNzo$xi!qB+78A)`ZQ8-R_1Y9dq-W4a24_TT>iG7(LCx&a&AESqO+xm?#o%vg9Hq0hI)>f`TCAVt^QXXPRYTc6ynaMMyO3 z{T3tYdI^cQ7;kv1idHSDSmg_Ez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ar/maquinadecafe/Pagamento.class b/target/classes/br/com/movimentocodar/maquinadecafe/Pagamento.class index b53983d0d97522560f5c2eb99fd998ee8cc73864..c890cd7d011d2a7491b8168eb820daf9f789e68a 100644 GIT binary patch delta 4059 zcmZ`*33yc175;BBGw)^cGD#*0FbNqZhCnjefIx%<5D1`9Llg)Cu0v)_MkbjsGXb|c z#l2Q5dbJW%7Pmm9Wp#+4wiUbC*3w0*wXND(ORKGRRS`-5dj|r3wt4y9dvotO_nh;e z|D5yQnELii=Zhx}J_lgBn7_yQp~$X+-$1p68q~@m`@|+EOw?PLfQbTDcQh0X%iYYM17%dUohO$6$;0q zHNHvzW49v^OB{YQ>I;T^!NWUNg_Vx4AuZUK2uH%#24cRBzTRkeofFNNWx)7v~AMyF-a+FdCm5y5N)#@&;E!wG#{R1q0_>XvHFd{L^5}iAE!# zK#zd2HW29xwOuLmvP;Z`xWK}NSS*K(qS`D1yVOEEmQgcp;EeMH!~!RlV}*g07A}@G z88d8`TDVMhXH;jJxI!Muc&6OMDhnM5G8LhCM>NtEie1;r!X<5sOk5`mjd7LD_@adykQDIrhJxW(OEehnjOv4CN896lfmk>yuwpnmd5cl! zT8|qI++^Wq+#*m#DpiVZdB~`kz8<$(xE+fHayq&~9f4(mNH`b>hMZWBJ1l%fIgu0Y z2_(XFLmN>$cUkx9VBP)-qxM->~pa<)Rtx?u~`J!!Z-P2#qt;%t@N4CQy)%?p5L9gY zjfLOhck)>F!?WMC@RqWk83+bV{DF?v*7~A-zS>%)`bP`zDAgRQo(|iIqxiFdzbNbP z%2%!0+`p3f6V&qi7Cyk=WnoTv=>Yy|;a{rhnTcq+wYiz(|ESLPpUB&fTIzE_Kz6DT%A3grhxySgUR#pQ-VQx;(e!y5#h{g-!+@ z@9PM~<5BrR-l(z8c~^IYdK1)*8zN7jK)080w0=R`@Q&PeEqCR$NHhO=SG`kA5EBhCiQbC_`D*?PWmA~_#bbTK6lV+MwfPd!L?Gfj zyhF82QD=&2a==|Fn&lC9;fN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ioDeAgua.class index 16510acb40990bee62276bd981ec9c263d868dfd..2366eb38909445805e73271315e7d94b546ed26e 100644 GIT binary patch delta 537 zcmYjOIZqow7=7RFn1#idfGrFH%yOB<946)rw;={XBB7L&6V^gT$VObEqos^ARCH97 z2*e?Q6bcXpP5wpxL8>6cHw%JjM(?}d`$qFOxEHb?p00iY7{#{}`zOs8qlFOvz9sXU zIZt|7hwts-@|JYu51HF3I9|cYZmeb3rB|>JCxlnzwoITqEH`FhJcx2kC^GLTt?tbRnpS_z7-dvI4A7h!6$vp0cmi43)?bf9)fcU8e)?88e} zEozWN5BGiKY#Gezw1w0oqKusEV+l>MA4u(L*-94F6c(b0pc)R3zmqn;l17;5g_O|G z3rjGv z7H;6ocRe#Q(}Y|hT&3%;V} E8EYw0wg3PC delta 424 zcmZvZJ4*vW6ot?1PO>st*C-(mVpb%H(e=H?sL@2DCN_#777CVj7O}CmwG`%;1R{b( zK(Mm$Pgn@nb|Rk5rV(t;?47;myXP`@&X=uTf1Y{(w$SRRd!gUOn^@3Y<5t&5s9I9o7a4R0k$C3JD7_451iwhW(gAiIu=KW~h065^0_Wo+KjF7_#gvk+8&M zKF0dqB)LF&;LRcf53_X7@pc$yx?y4d8!0L;7dbcpe@1*!&~7w!8;lPTlLJJ8wh$pW zsNc_?Dr1LBop)iy{mVZ~seXuYM$G-Qkcnjy3`SnznINf5RyEKxA0a5}*x@h5uLkze GMCKPq0x>KA diff --git a/target/classes/br/com/movimentocodar/maquinadecafe/teste.class b/target/classes/br/com/movimentocodar/maquinadecafe/teste.class deleted file mode 100644 index 5ddefff22df9d90b5f55cb43fa2059663f0eb013..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 312 zcma)1%TB{E5S-1Uflz40A8?}};SZqVg2X9;1E}|nW588x3)ks?aYEw22k=pdO~ePV zE6wc8O1qlxpU*Dm6>F?DT181lt-B=_o`2-I|sYwIn#RuqJj10BlxCU|@ R3C^dv6h0P3I1$XS_yrn$NOk}K diff --git a/target/cupom.json b/target/cupom.json index 5765a05..714b466 100644 --- a/target/cupom.json +++ b/target/cupom.json @@ -1,71 +1,281 @@ [ { - "valor" : 48.50, + "valor" : 4.50, + "ativo" : false, + "codigo" : "NOV21-AR3UCCB63", + "validade" : "12/02/2022" +}, { + "valor" : 3.00, + "ativo" : false, + "codigo" : "NOV21-AR3UCCCAC", + "validade" : "12/02/2022" +}, { + "valor" : 1.50, + "ativo" : false, + "codigo" : "NOV21-AR3UCCCAG", + "validade" : "12/02/2022" +}, { + "valor" : 0.50, + "ativo" : false, + "codigo" : "NOV21-AR3UCCCAK", + "validade" : "12/02/2022" +}, { + "valor" : 4.50, + "ativo" : false, + "codigo" : "NOV21-AR3UCDRGQ", + "validade" : "12/02/2022" +}, { + "valor" : 3.00, + "ativo" : false, + "codigo" : "NOV21-AR3UCDRHA", + "validade" : "12/02/2022" +}, { + "valor" : 1.50, + "ativo" : false, + "codigo" : "NOV21-AR3UCDRHF", + "validade" : "12/02/2022" +}, { + "valor" : 0.50, + "ativo" : true, + "codigo" : "NOV21-AR3UCDRHK", + "validade" : "12/02/2022" +}, { + "valor" : 4.50, + "ativo" : false, + "codigo" : "NOV21-AR3UCR5J2", + "validade" : "12/02/2022" +}, { + "valor" : 3.00, + "ativo" : false, + "codigo" : "NOV21-AR3UCR5KT", + "validade" : "12/02/2022" +}, { + "valor" : 1.50, + "ativo" : false, + "codigo" : "NOV21-AR3UCR5KZ", + "validade" : "12/02/2022" +}, { + "valor" : 0.50, + "ativo" : true, + "codigo" : "NOV21-AR3UCR5K5", + "validade" : "12/02/2022" +}, { + "valor" : 4.50, + "ativo" : false, + "codigo" : "NOV21-AR3UCSBUV", + "validade" : "12/02/2022" +}, { + "valor" : 3.00, + "ativo" : false, + "codigo" : "NOV21-AR3UCSBVI", + "validade" : "12/02/2022" +}, { + "valor" : 1.50, + "ativo" : false, + "codigo" : "NOV21-AR3UCSBVN", + "validade" : "12/02/2022" +}, { + "valor" : 0.50, + "ativo" : false, + "codigo" : "NOV21-AR3UCSBVR", + "validade" : "12/02/2022" +}, { + "valor" : 4.50, + "ativo" : false, + "codigo" : "NOV21-AR3YA6NLS", + "validade" : "16/02/2022" +}, { + "valor" : 3.00, + "ativo" : false, + "codigo" : "NOV21-AR3YA6NMD", + "validade" : "16/02/2022" +}, { + "valor" : 1.50, + "ativo" : false, + "codigo" : "NOV21-AR3YA6NMJ", + "validade" : "16/02/2022" +}, { + "valor" : 0.50, + "ativo" : false, + "codigo" : "NOV21-AR3YA6NMN", + "validade" : "16/02/2022" +}, { + "valor" : 2.0, + "ativo" : false, + "codigo" : "NOV21-AR3YBGTLT", + "validade" : "16/02/2022" +}, { + "valor" : 1.50, "ativo" : true, - "codigo" : "NOV21-4907469908172", - "validade" : "02/02/2022" + "codigo" : "NOV21-AR3YBGTMH", + "validade" : "16/02/2022" +}, { + "valor" : 2.0, + "ativo" : false, + "codigo" : "NOV21-AR3YBHIUE", + "validade" : "16/02/2022" }, { - "valor" : 99.50, + "valor" : 1.50, "ativo" : true, - "codigo" : "NOV21-4907470000326", - "validade" : "02/02/2022" + "codigo" : "NOV21-AR3YBHIUZ", + "validade" : "16/02/2022" }, { - "valor" : 49.50, + "valor" : 1.0, "ativo" : true, - "codigo" : "NOV21-4907470233741", - "validade" : "02/02/2022" + "codigo" : "NOV21-AR3YCJ5IX", + "validade" : "16/02/2022" }, { - "valor" : 48.50, + "valor" : 1.0, "ativo" : true, - "codigo" : "NOV21-4907471432178", - "validade" : "02/02/2022" + "codigo" : "NOV21-AR3YCJ5JE", + "validade" : "16/02/2022" +}, { + "valor" : 2.0, + "ativo" : false, + "codigo" : "NOV21-AR3YCJ5JN", + "validade" : "16/02/2022" }, { - "valor" : 48.50, + "valor" : 1.50, "ativo" : true, - "codigo" : "NOV21-BHacNq8t", - "validade" : "02/02/2022" + "codigo" : "NOV21-AR3YCJ5JQ", + "validade" : "16/02/2022" +}, { + "valor" : 4.50, + "ativo" : false, + "codigo" : "NOV21-AR3YCJ5JW", + "validade" : "16/02/2022" +}, { + "valor" : 3.00, + "ativo" : false, + "codigo" : "NOV21-AR3YCJ5JZ", + "validade" : "16/02/2022" +}, { + "valor" : 1.50, + "ativo" : false, + "codigo" : "NOV21-AR3YCJ5J5", + "validade" : "16/02/2022" }, { - "valor" : 49.00, + "valor" : 0.50, + "ativo" : false, + "codigo" : "NOV21-AR3YCJ5KA", + "validade" : "16/02/2022" +}, { + "valor" : 1.0, "ativo" : true, - "codigo" : "NOV21-AR3JYRATGE======", - "validade" : "02/02/2022" + "codigo" : "NOV21-AR3YCLYTM", + "validade" : "16/02/2022" }, { - "valor" : 18.50, + "valor" : 1.0, "ativo" : true, - "codigo" : "NOV21-0HR9OJA9TC======", - "validade" : "02/02/2022" + "codigo" : "NOV21-AR3YCLYTY", + "validade" : "16/02/2022" +}, { + "valor" : 2.0, + "ativo" : false, + "codigo" : "NOV21-AR3YCLYUB", + "validade" : "16/02/2022" }, { - "valor" : 49.00, + "valor" : 1.50, "ativo" : true, - "codigo" : "NOV21-AR3JYU55HA======", - "validade" : "02/02/2022" + "codigo" : "NOV21-AR3YCLYUE", + "validade" : "16/02/2022" +}, { + "valor" : 4.50, + "ativo" : false, + "codigo" : "NOV21-AR3YCLYUK", + "validade" : "16/02/2022" +}, { + "valor" : 3.00, + "ativo" : false, + "codigo" : "NOV21-AR3YCLYUM", + "validade" : "16/02/2022" +}, { + "valor" : 1.50, + "ativo" : false, + "codigo" : "NOV21-AR3YCLYUQ", + "validade" : "16/02/2022" }, { - "valor" : 49.00, + "valor" : 0.50, + "ativo" : false, + "codigo" : "NOV21-AR3YCLYUS", + "validade" : "16/02/2022" +}, { + "valor" : 1.0, "ativo" : true, - "codigo" : "NOV21-AR3JYVLRPE======", - "validade" : "02/02/2022" + "codigo" : "NOV21-AR3YCL3AG", + "validade" : "16/02/2022" }, { - "valor" : 49.00, + "valor" : 1.0, "ativo" : true, - "codigo" : "NOV21-AR3JYWWYIA======", - "validade" : "02/02/2022" + "codigo" : "NOV21-AR3YCL3AU", + "validade" : "16/02/2022" +}, { + "valor" : 2.0, + "ativo" : false, + "codigo" : "NOV21-AR3YCL3A4", + "validade" : "16/02/2022" }, { - "valor" : 19.00, + "valor" : 1.50, "ativo" : true, - "codigo" : "NOV21-AR3JYZD5UM=====", - "validade" : "02/02/2022" + "codigo" : "NOV21-AR3YCL3A7", + "validade" : "16/02/2022" +}, { + "valor" : 4.50, + "ativo" : false, + "codigo" : "NOV21-AR3YCL3BF", + "validade" : "16/02/2022" +}, { + "valor" : 3.00, + "ativo" : false, + "codigo" : "NOV21-AR3YCL3BI", + "validade" : "16/02/2022" +}, { + "valor" : 1.50, + "ativo" : false, + "codigo" : "NOV21-AR3YCL3BM", + "validade" : "16/02/2022" +}, { + "valor" : 0.50, + "ativo" : false, + "codigo" : "NOV21-AR3YCL3BQ", + "validade" : "16/02/2022" }, { - "valor" : 49.00, + "valor" : 1.0, "ativo" : true, - "codigo" : "NOV21-38ac679ec802f7152a883637b757a9e66fd10f2b", - "validade" : "02/02/2022" + "codigo" : "NOV21-AR3YCNOWD", + "validade" : "16/02/2022" }, { - "valor" : 48.50, + "valor" : 1.0, "ativo" : true, - "codigo" : "NOV21-AR3JY6CYG", - "validade" : "02/02/2022" + "codigo" : "NOV21-AR3YCNOWP", + "validade" : "16/02/2022" }, { - "valor" : 18.50, + "valor" : 2.0, + "ativo" : false, + "codigo" : "NOV21-AR3YCNOWX", + "validade" : "16/02/2022" +}, { + "valor" : 1.50, "ativo" : true, - "codigo" : "NOV21-AR3KPM43S", - "validade" : "02/02/2022" + "codigo" : "NOV21-AR3YCNOW3", + "validade" : "16/02/2022" +}, { + "valor" : 4.50, + "ativo" : false, + "codigo" : "NOV21-AR3YCNOXB", + "validade" : "16/02/2022" +}, { + "valor" : 3.00, + "ativo" : false, + "codigo" : "NOV21-AR3YCNOXD", + "validade" : "16/02/2022" +}, { + "valor" : 1.50, + "ativo" : false, + "codigo" : "NOV21-AR3YCNOXH", + "validade" : "16/02/2022" +}, { + "valor" : 0.50, + "ativo" : false, + "codigo" : "NOV21-AR3YCNOXK", + "validade" : "16/02/2022" } ] \ No newline at end of file diff --git a/target/test-classes/CupomTest.class b/target/test-classes/CupomTest.class new file mode 100644 index 0000000000000000000000000000000000000000..fdf42365e35b1e0e5bedc0a6e3cb7c6c48ec67f6 GIT binary patch literal 2023 zcmb7FTUQ%Z7~LlXCJh6GtI|SC5!zfR19+h}*b1R28bE=jg4fAp2!olKI+=++`0Q`+ zZ}<|ZUCZUOKg#7klQD@d)-vW{&V7IT+uuGXfBgCDZvZxMoOl| z)19hzP`)q?UtnOvaxDL`KwmmjQjieHmOagIZOwKYmTfw|Yq%BN(`@~_z;g78Y3OIB zRtR3WPCW?)eMt;LRWPJt7$X7`VGLXM&$TV9x@{Vkt=9yUhF%NIgEN8Y^me9r-KM;P zQGraa;q4?+7?+t%NYLvcGbPD!O2unc6RhyooC|dQz>H#Z>xAm#u+ls z=_evu6*^18Jyh|o#7edf9(w_&^Vm@Eo{GnKA}}ta*sk%d<-6Kmt0lCY5m@Y&vrr>Q zzPlnV*E8D`HdSm%=OpT;PXewdC%08RmE}ztdd&!Gy4RtW#|J7t#4ba9e{MPgkGexe zz?ote%XENt;8b0 zPm5Q~hRJQa-KOG$VT4y-V5w)9I(5SJH>Ah{Q`cWq(sw#HGuJb=P3Yv)9}M$_Z}CM^ zpwl6tdo5SnJ!r4+i8u@#URASX)h(vJ={T;>>%v21rFSyIAXe98w|{^Fn_7~uDaBaN+K+n>FJ_=TMqj`@|# zKoZaRRa+ZS!gG!UKI3X%c=%_wan3z_1?A)tH;N-yNbbEt>SXB>WBa)WO-$x;O-wg2 z+r-^YccF>&6_z{kZu6l6hLFGrzbQ;%l&{?wpO6WxV>0BCZN-XsB(Q=LoRZHFa`+ry zkogqm@g=?@tFMVB6a5Bd_GC5&TY*ZO`%e+~Y){smU0zP~{)l_Ay>os#_dOUE$I1NbN0A*!P#3C|qG@?4y?` z#_*g&GVRi}#dLuMzsLW``xr->8fD2e7c!k|AxBL6u^95BeVCP0GWIY1&d4K%>R-JT B=0pGh literal 0 HcmV?d00001 diff --git a/target/test-classes/MaquinaDeCafeTest.class b/target/test-classes/MaquinaDeCafeTest.class new file mode 100644 index 0000000000000000000000000000000000000000..605349a71be738b5a050a15f3eb0d5d530802e71 GIT binary patch literal 5831 zcmb`L`&Sg_8OOiFF6_FF#;isqUb1RbF3KXHF+fyAh}Z=ch!KrVhTYd?baw`3XA!hX z+U91Oq-pNAwz-;yByFQHNXtnt$J74MzomaePrvWX?6M%>9Fya5mz{m*o%j2Bp6B~K z@Sp$v^=|-L@s|k75C|ctq8t?pR-DsDwRlD|(($8%=S0$0P|>Ozy1h?9psM;r1Ys-* zA);a_R0aD?D;+`u$f_Su?|(yUaMF`T#iY)fca z1#3li*dCwvtAkb5i66Fo%MvWdT_LPcaW|q0?(Wt`^17iN67AYq(JyjTr@E)?GP=#= zc?Ac4=p#c|rC@^tK{w+E$8FJOS=#u~yj@fs!AgmIje?bhb;m5-@R&rf8kI5{_bRBY zN)%RchC7Z@WU+rl4xj zVj#2etU0P@g<+dXlOc;|U2Z9nB)7PP7r|Dkp<2NnKezOXoUleU+q87^kZ4QiwFs)@ z20Ik&^0UFL$VE_#I*BN*prtC|=l)v{KmZ}^nvISLY@}t1H>zmDZf3`@MG`5I&<&AO zu)6BB8xW^Jn8RG|1fv!YsMw1Kxm`|VL{c{m%{nLs^^~Tdj*0B&jPClD2wKn@!b2+d zVZVYJ|F+)K%BzkXk(pJC zhgBR#mx47ZVGAqElCgU9QITQjlKG@&`PbyGXCeLsi4eL~^x&vZO@&8=db&<@Bpzp| zcKE{RJyOa)F17b6*zT1;iLbSk1k!anFOdBz9+6JCETaz!s}Mz5vyZAci2(&++jK*( zU=>3q>RC4{27P7|9DGDO##eN&P7m z0%sLO+(7qRdBG!9oszXb#G-Eu;hchcKN%*AzTM0wgl@C=bp&KcvnmW3PcKA`VGMKE z-66;f@wMv^%{ZZFH8X+{ch9_v(ULuPhcU)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)8F=QqxtI(ed*nM_JU?84LRQqF zqR+Nsef{&2-j&~ZT0nSwHi)CUnt4su=tfTMPCd8hi8CC$(nSKdivO?w7_Yw+O847M zS!*)2*NhX&*!hHWl50z6upXY`jp7;X zhl{63KgHk~GF-a2nOM#ZWqw5e)f0?=pAbL&^~d4~vM0Da{LTqxo?^j(CSuTO0vfm! z`gubQAd5ks=^@N=zJ_4}kHiTr5H!d2B`njE@XgdxgQDTyp}7E? zs253doP;Kr>?CPsNpq4kbGU&^B#~#9Q|HoMZ_{0B(_Q%QbWLgRF#&;Mo9PCXGTqVN rtXh!-;*1;JFc8apg&EJVJhO3DV-1IPF1>LE;vd>}z&07a2lxL5jVZAV literal 0 HcmV?d00001 diff --git a/target/test-classes/TestRunner.class b/target/test-classes/TestRunner.class new file mode 100644 index 0000000000000000000000000000000000000000..0a63234e2ffbcf8e1c2700c29161a3c43b09ed1f GIT binary patch literal 2241 zcmaJ?-&Y$&6#fPR8^Tf`{A$p))Pf}xy0u!Z1W_8qQUe7-L8w}XWC#nJ-E@D@;*ZDv z5A~d$nuhDa=-r3!dgi!ZkcjnHWZ|?Way?6ik=f!UTrtn=1O=wmS zQPF}{hOS+{&ozUa1?~3MuE@Czty8+GyVDHKqscV|QHCDh$#Zo>o3U+vkkK7C21Vku zGjvuV(gt@N1sx3C3;e#Pn|xNJ`Lhj7&b3a2O^=?`Do2kxFJ7wyy}sGu)Jnt4~Eg28aO9=NbA&Yqkd@Q^`#Q35K?` zSF(ySIt8yWbS&`#FACGO0@E3Weu5SDK6fo!w`Rpm!Q%lL1?N-@;XFfBcZDq-$a^#y zoaJjZAKFvxxPV~=BP!m+MTU4)&Wa0zvcsK4@sRW<**E2mq>3?IVu+Z&xwnE{b6F_` z6AS~d&?1I$XezGYEr#}jaOb#gc(#-@UcvI?l-EfyzKwGV-eEXZ4NtBpc$ZOE>dHY6kjp2rhG-gRSa$TfbW2je%P<69FuGcW9;uGl_b*;b}r&^d- zaSNZ4dPTk`(w0e7)^&G>Mvlu(msGl5n>Zm{O)7aO_J zMroC{@+4YkMmNQxSKJczD&I2563d3l0x3|Dcp;)o3<=Htgr%O3ItBPHgl|^-N!?Ik*wRvel zxI0$f>1;(QhWoG;IPzX8?BQz1)6IQrPiO(XAW`Rdj{403!{gfP4;=&0o7~JB!Wqt3 z)}B{NHRf%NrEcRYNpXUEtk27g2Q3#SRkAde;#Vfsi67VYxzfMzioJ;c}e7K#4=f7@A) literal 0 HcmV?d00001 From 766bb1a3678fafb74119242ca78c7da174b962de Mon Sep 17 00:00:00 2001 From: Lilian Date: Tue, 16 Nov 2021 20:52:33 -0300 Subject: [PATCH 9/9] =?UTF-8?q?Atualiza=C3=A7=C3=A3o=20do=20Desafio=20-=20?= =?UTF-8?q?Test=20runner?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/test/java/TestRunner.java | 24 +-- target/cupom.json | 240 +++++++++++++++++++++++++++ target/test-classes/TestRunner.class | Bin 2241 -> 2241 bytes 3 files changed, 252 insertions(+), 12 deletions(-) diff --git a/src/test/java/TestRunner.java b/src/test/java/TestRunner.java index 15f705b..97e3323 100644 --- a/src/test/java/TestRunner.java +++ b/src/test/java/TestRunner.java @@ -6,19 +6,19 @@ public class TestRunner { public static void main(String[] args) { - ArrayList resultList = new ArrayList(); - resultList.add(JUnitCore.runClasses(MaquinaDeCafeTest.class)); - resultList.add(JUnitCore.runClasses(CupomTest.class)); - resultList.add(JUnitCore.runClasses(PagamentoTest.class)); - resultList.add(JUnitCore.runClasses(ReservatorioDeAguaTest.class)); + ArrayList resultList = new ArrayList(); + resultList.add(JUnitCore.runClasses(MaquinaDeCafeTest.class)); + resultList.add(JUnitCore.runClasses(CupomTest.class)); + resultList.add(JUnitCore.runClasses(PagamentoTest.class)); + resultList.add(JUnitCore.runClasses(ReservatorioDeAguaTest.class)); - for (Result result: resultList) { - for (Failure failure : result.getFailures()) { - System.out.println(result.getClass().getName() + " - " + failure.toString()); - } - - System.out.println(result.getClass().getName() + " - " + result.wasSuccessful()); - } + for (Result result : resultList) { + for (Failure failure : result.getFailures()) { + System.out.println(failure.toString()); + } + System.out.println(result.wasSuccessful()); + } } } + diff --git a/target/cupom.json b/target/cupom.json index 714b466..5c18589 100644 --- a/target/cupom.json +++ b/target/cupom.json @@ -278,4 +278,244 @@ "ativo" : false, "codigo" : "NOV21-AR3YCNOXK", "validade" : "16/02/2022" +}, { + "valor" : 1.0, + "ativo" : true, + "codigo" : "NOV21-AR3YCSRKQ", + "validade" : "16/02/2022" +}, { + "valor" : 1.0, + "ativo" : true, + "codigo" : "NOV21-AR3YCSRK6", + "validade" : "16/02/2022" +}, { + "valor" : 2.0, + "ativo" : false, + "codigo" : "NOV21-AR3YCSRLG", + "validade" : "16/02/2022" +}, { + "valor" : 1.50, + "ativo" : true, + "codigo" : "NOV21-AR3YCSRLK", + "validade" : "16/02/2022" +}, { + "valor" : 4.50, + "ativo" : false, + "codigo" : "NOV21-AR3YCSRLQ", + "validade" : "16/02/2022" +}, { + "valor" : 3.00, + "ativo" : false, + "codigo" : "NOV21-AR3YCSRLS", + "validade" : "16/02/2022" +}, { + "valor" : 1.50, + "ativo" : false, + "codigo" : "NOV21-AR3YCSRLW", + "validade" : "16/02/2022" +}, { + "valor" : 0.50, + "ativo" : false, + "codigo" : "NOV21-AR3YCSRLZ", + "validade" : "16/02/2022" +}, { + "valor" : 1.0, + "ativo" : true, + "codigo" : "NOV21-AR3YCUGMG", + "validade" : "16/02/2022" +}, { + "valor" : 1.0, + "ativo" : true, + "codigo" : "NOV21-AR3YCUGMT", + "validade" : "16/02/2022" +}, { + "valor" : 2.0, + "ativo" : false, + "codigo" : "NOV21-AR3YCUGM2", + "validade" : "16/02/2022" +}, { + "valor" : 1.50, + "ativo" : true, + "codigo" : "NOV21-AR3YCUGM6", + "validade" : "16/02/2022" +}, { + "valor" : 4.50, + "ativo" : false, + "codigo" : "NOV21-AR3YCUGND", + "validade" : "16/02/2022" +}, { + "valor" : 3.00, + "ativo" : false, + "codigo" : "NOV21-AR3YCUGNG", + "validade" : "16/02/2022" +}, { + "valor" : 1.50, + "ativo" : false, + "codigo" : "NOV21-AR3YCUGNK", + "validade" : "16/02/2022" +}, { + "valor" : 0.50, + "ativo" : false, + "codigo" : "NOV21-AR3YCUGNN", + "validade" : "16/02/2022" +}, { + "valor" : 2.0, + "ativo" : false, + "codigo" : "NOV21-AR3YC2GY2", + "validade" : "16/02/2022" +}, { + "valor" : 1.50, + "ativo" : true, + "codigo" : "NOV21-AR3YC2GZS", + "validade" : "16/02/2022" +}, { + "valor" : 4.50, + "ativo" : false, + "codigo" : "NOV21-AR3YC2GZ5", + "validade" : "16/02/2022" +}, { + "valor" : 3.00, + "ativo" : false, + "codigo" : "NOV21-AR3YC2G2B", + "validade" : "16/02/2022" +}, { + "valor" : 1.50, + "ativo" : false, + "codigo" : "NOV21-AR3YC2G2F", + "validade" : "16/02/2022" +}, { + "valor" : 0.50, + "ativo" : false, + "codigo" : "NOV21-AR3YC2G2J", + "validade" : "16/02/2022" +}, { + "valor" : 2.0, + "ativo" : false, + "codigo" : "NOV21-AR3YC2OHM", + "validade" : "16/02/2022" +}, { + "valor" : 1.50, + "ativo" : true, + "codigo" : "NOV21-AR3YC2OJT", + "validade" : "16/02/2022" +}, { + "valor" : 4.50, + "ativo" : false, + "codigo" : "NOV21-AR3YC2QMO", + "validade" : "16/02/2022" +}, { + "valor" : 3.00, + "ativo" : false, + "codigo" : "NOV21-AR3YC2RSW", + "validade" : "16/02/2022" +}, { + "valor" : 1.50, + "ativo" : false, + "codigo" : "NOV21-AR3YC2RTH", + "validade" : "16/02/2022" +}, { + "valor" : 0.50, + "ativo" : false, + "codigo" : "NOV21-AR3YC2RTX", + "validade" : "16/02/2022" +}, { + "valor" : 2.0, + "ativo" : false, + "codigo" : "NOV21-AR3YC22II", + "validade" : "16/02/2022" +}, { + "valor" : 1.50, + "ativo" : true, + "codigo" : "NOV21-AR3YC22KP", + "validade" : "16/02/2022" +}, { + "valor" : 4.50, + "ativo" : false, + "codigo" : "NOV21-AR3YC22LS", + "validade" : "16/02/2022" +}, { + "valor" : 3.00, + "ativo" : false, + "codigo" : "NOV21-AR3YC22L6", + "validade" : "16/02/2022" +}, { + "valor" : 1.50, + "ativo" : false, + "codigo" : "NOV21-AR3YC22MP", + "validade" : "16/02/2022" +}, { + "valor" : 0.50, + "ativo" : false, + "codigo" : "NOV21-AR3YC22NA", + "validade" : "16/02/2022" +}, { + "valor" : 2.0, + "ativo" : false, + "codigo" : "NOV21-AR3YC4G7X", + "validade" : "16/02/2022" +}, { + "valor" : 1.50, + "ativo" : true, + "codigo" : "NOV21-AR3YC4HB6", + "validade" : "16/02/2022" +}, { + "valor" : 4.50, + "ativo" : false, + "codigo" : "NOV21-AR3YC4HDC", + "validade" : "16/02/2022" +}, { + "valor" : 3.00, + "ativo" : false, + "codigo" : "NOV21-AR3YC4HDO", + "validade" : "16/02/2022" +}, { + "valor" : 1.50, + "ativo" : false, + "codigo" : "NOV21-AR3YC4HD7", + "validade" : "16/02/2022" +}, { + "valor" : 0.50, + "ativo" : false, + "codigo" : "NOV21-AR3YC4HER", + "validade" : "16/02/2022" +}, { + "valor" : 1.0, + "ativo" : true, + "codigo" : "NOV21-AR3YC5JTW", + "validade" : "16/02/2022" +}, { + "valor" : 1.0, + "ativo" : true, + "codigo" : "NOV21-AR3YC5JUE", + "validade" : "16/02/2022" +}, { + "valor" : 2.0, + "ativo" : false, + "codigo" : "NOV21-AR3YC5JUL", + "validade" : "16/02/2022" +}, { + "valor" : 1.50, + "ativo" : true, + "codigo" : "NOV21-AR3YC5JUO", + "validade" : "16/02/2022" +}, { + "valor" : 4.50, + "ativo" : false, + "codigo" : "NOV21-AR3YC5JUU", + "validade" : "16/02/2022" +}, { + "valor" : 3.00, + "ativo" : false, + "codigo" : "NOV21-AR3YC5JUX", + "validade" : "16/02/2022" +}, { + "valor" : 1.50, + "ativo" : false, + "codigo" : "NOV21-AR3YC5JU3", + "validade" : "16/02/2022" +}, { + "valor" : 0.50, + "ativo" : false, + "codigo" : "NOV21-AR3YC5JU6", + "validade" : "16/02/2022" } ] \ No newline at end of file diff --git a/target/test-classes/TestRunner.class b/target/test-classes/TestRunner.class index 0a63234e2ffbcf8e1c2700c29161a3c43b09ed1f..b1fc827cba79f907a1adac4d6742a15b5a7f66b4 100644 GIT binary patch delta 13 UcmX>ocu;VI83&`-WOI%#03Wgh1^@s6 delta 13 UcmX>ocu;VI83&{IWOI%#03Wvm2LJ#7