From d20871c191c913c33a35efe234c2c7619c4d959b Mon Sep 17 00:00:00 2001 From: = <=> Date: Tue, 23 Apr 2024 19:31:56 -0300 Subject: [PATCH] feat: Social Media Screen Updated --- .../challenge01-conversormoedas/bin/App.class | Bin 5025 -> 5142 bytes .../bin/RenderScreen.class | Bin 2770 -> 2794 bytes .../challenge01-conversormoedas/src/App.java | 107 +++++++++--------- .../src/RenderScreen.java | 30 ++--- 4 files changed, 68 insertions(+), 69 deletions(-) diff --git a/challenge-backend/challenge01-conversormoedas/bin/App.class b/challenge-backend/challenge01-conversormoedas/bin/App.class index 4ec933d2b692fd36277c4b3f26899132975dcba7..e97a5b5c5b71c411e644d9cb31edcd0f884432b6 100644 GIT binary patch delta 1202 zcmZ`%Yiv_>6#t#}_TJm}c3V5T(W$kJ7;q088`NYnwQPcuIRzv5MU&2zQP;JkTZtwn z^^5Tlzx@+4znGxtK+stx6{n)k2M7+|2>5<0peVivGJp4OpG-VAIp_2|f9Ln_rbQ1d z_U$_}u^Yf8QdRcdYc#h0kC@mbm>;94vN5k@;*r^($!sx~Z;N&2i~ZTuP;7N-Fh3MC z@u*-yHj^7j_hoVy+>#%RXL9kr*_zgZUDMi^-e_V}P=9;AI9%*aJ5^U~DCF1mpM;StS<8})&Ia>2L4oc`kUo%wcY=a_PdGG zs>kY*Git<&h6n(@HK}Yd9ZSU8#T1v?Yn|s3k2+yBX@(%G%KoUjG!PcQS{1lM40RyT z^$YB?rg+UBUFoEab#r;I}JYL{MBfMibN-uKhR@C4nyv+1|9yQ4pFHX{X zg`*8jbJVL`XW}&ivIu3i^>udcVWb`U3>nZ3>@^TJ5ECvm@CGo0UYP$4iyJHm2B*jxUY*lt|kdKnLQ-#T8EY<9tkYO6i>5dAr26yINn?I-27sA zo1O=IR4Eu=`c4J!wP_JeON2hOT~EYwR-%H#7wfiD;|=Q-eB5S4j9vJ=Yw=i{#{Wb_ ztDrD}Z`IM@b=TO;+Oh)QajB5`D;+*vWbb@@&-c*~=Ic(<^U#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*i{~qNzQEt!!xwxJI>l@FM8mKch7W13CVYPb-b@21 diff --git a/challenge-backend/challenge01-conversormoedas/bin/RenderScreen.class b/challenge-backend/challenge01-conversormoedas/bin/RenderScreen.class index 2ffb9a3658d53bcbde8b9fa373a08c1e5d37c9ff..30ccc918f660cc7c783a9a4a85b51feb657e88a4 100644 GIT binary patch delta 453 zcmZ{g-AV#c6ouFE9LHf$f=Oe9l7TWaC?bNcyofGRGc7I6{xh}g$IR?kqj%`s2faa7 zNC@@-b=MPg-9toYR3d`*fxXt=>w^RP-SO#AUcc%u0LF1uRl;;YMu0%`{ZpzSr>zKK zhNtKliwKn8Q9Hk!g<>vWl942^xQ9oxx;w96 z8LJko@Db*qYgp%g)-P>Zk-`=)v7jwO!1PK*S7Abozp;>%N5O(a-edOC5RQ1jeCs@r zQ6lKjn-!l3MWVV-Co)cNB#m7VxOv#@mMka}xP)~*W~4N|_Sew&fNoD6L7?T;a9d|v zI`{;wj;IkY2vl8U4bUX@JYy+V!$!i`rGL=QIuhs{U{&F%^vmCc|}60YRj;U6g)up0T)$1#}QtcgqEH--bm3 z(K+bLsZLWu5-TE>30jN#q3$(wGw+=&9b}BGj1*RBn(r6ZWu&3gYhJT&5b)~xxvIc| z2z}>+f&o*+4jr+&ISnPMTW@^ZHk1iknlCu65*zl}Vxlq%IbfREvft1vm25@C5gif+ z$jN<5xZ*B)AJKP*9#<7JK!Yp69}G2c-~pXg%-8G~iz*5J8C;TcJz**Kh_%ITZtKPP}D5V1XT=X=&P@MUFioaE3f%92;A8zknjcb~fK-{$9OTe)<7(B&HtX I7^mp^22yBeoB#j- diff --git a/challenge-backend/challenge01-conversormoedas/src/App.java b/challenge-backend/challenge01-conversormoedas/src/App.java index a9cabab..e16be9a 100644 --- a/challenge-backend/challenge01-conversormoedas/src/App.java +++ b/challenge-backend/challenge01-conversormoedas/src/App.java @@ -4,43 +4,43 @@ import java.net.http.HttpRequest; import java.net.http.HttpResponse; - public class App { - public static void main(String[] args) throws Exception , InterruptedException{ - + public static void main(String[] args) throws Exception, InterruptedException { + @SuppressWarnings("resource") Scanner scanner = new Scanner(System.in); RenderScreen renderscreen = new RenderScreen(); char novaConversao = 'S'; String json = ""; - int[] actualCurrency = {0,146,42,20,42,20,146}; - + int[] actualCurrency = { 0, 146, 42, 20, 42, 20, 146 }; + while (novaConversao == 'S') { novaConversao = 'N'; renderscreen.generateMenu(); int opcaoSelecionada = scanner.nextInt(); - + if (opcaoSelecionada > 0 && opcaoSelecionada < 7) { System.out.println("DIGITE O VALOR A CONVERTER"); double value = scanner.nextDouble(); - // Buscar Cotação - try{ - HttpClient client = HttpClient.newHttpClient(); - - HttpRequest request = HttpRequest.newBuilder() - .uri(URI.create("https://v6.exchangerate-api.com/v6/24be77b499ee270705b19218/latest/"+currentCurrency(opcaoSelecionada))) - .build(); - - HttpResponse response = client - .send(request,HttpResponse.BodyHandlers.ofString()); - - json = response.body(); + // Buscar Cotação + try { + HttpClient client = HttpClient.newHttpClient(); + + HttpRequest request = HttpRequest.newBuilder() + .uri(URI.create("https://v6.exchangerate-api.com/v6/24be77b499ee270705b19218/latest/" + + currentCurrency(opcaoSelecionada))) + .build(); + + HttpResponse response = client + .send(request, HttpResponse.BodyHandlers.ofString()); + + json = response.body(); } catch (Exception e) { - System.out.println("Cotação indisponível :"+ e.getMessage()); + System.out.println("Cotação indisponível :" + e.getMessage()); } - double currency = convertCurrency(0,value,extractJson(json,actualCurrency[opcaoSelecionada])); + double currency = convertCurrency(0, value, extractJson(json, actualCurrency[opcaoSelecionada])); renderscreen.selectConversion(opcaoSelecionada); renderscreen.printConversion(value, currency); @@ -55,46 +55,46 @@ public static void main(String[] args) throws Exception , InterruptedException{ } System.out.println("************************"); - System.out.println("OBRIGADO POR UTILIZAR O "); + System.out.println("OBRIGADO POR UTILIZAR O "); System.out.println("CONVERSOR DE MOEDAS. "); - System.out.println(" "); - System.out.println("PROGRAMA ONE 2024 "); - System.out.println("PROGRAMA ONE 2024 "); - System.out.println("*******************************************"); + System.out.println("------------------------"); + System.out.println(" PROGRAMA ONE 2024 "); + System.out.println(" Aluno: Douglas Ramos "); + System.out.println("linkedin.com/in/douglas-ramos-dev"); + System.out.println("youtube.com/@profdomdev"); + System.out.println("github.com/douginfodev"); + System.out.println("************************"); } - public static double convertCurrency(int operation, double value1, double value2){ + public static double convertCurrency(int operation, double value1, double value2) { double valueConverted = 0; - - if(operation == 0){ - valueConverted = (value1 * value2); + + if (operation == 0) { + valueConverted = (value1 * value2); + } else { + valueConverted = (value1 / value2); } - else - { - valueConverted = (value1 / value2); - } - - System.out.println("Value 2 ="+value2); + System.out.println("Value 2 =" + value2); return valueConverted; } - public static double extractJson(String json,int posicao) throws Exception { + public static double extractJson(String json, int posicao) throws Exception { double value = 0.0; - try{ - String[] listaValores = json.split("rates"); - String[] currency = listaValores[1].split(","); - int auxStrLength = currency[posicao].length(); - String auxStr = currency[posicao].substring(9,auxStrLength); - value = Double.parseDouble(auxStr); + try { + String[] listaValores = json.split("rates"); + String[] currency = listaValores[1].split(","); + int auxStrLength = currency[posicao].length(); + String auxStr = currency[posicao].substring(9, auxStrLength); + value = Double.parseDouble(auxStr); + return value; + } catch (Exception e) { + System.out.println("Erro na Cotação" + e.getMessage()); + } return value; - } catch (Exception e) { - System.out.println("Erro na Cotação"+ e.getMessage()); - } - return value; } - public static String currentCurrency(int option){ + public static String currentCurrency(int option) { String currency = ""; switch (option) { @@ -104,17 +104,16 @@ public static String currentCurrency(int option){ break; case 3: case 4: - currency = "USD"; + currency = "USD"; break; - case 5: - case 6: - currency = "EUR"; + case 5: + case 6: + currency = "EUR"; break; - default: + default: break; } return currency; } -} - +} \ No newline at end of file diff --git a/challenge-backend/challenge01-conversormoedas/src/RenderScreen.java b/challenge-backend/challenge01-conversormoedas/src/RenderScreen.java index 3f6756e..ae8e348 100644 --- a/challenge-backend/challenge01-conversormoedas/src/RenderScreen.java +++ b/challenge-backend/challenge01-conversormoedas/src/RenderScreen.java @@ -39,38 +39,38 @@ public void selectConversion(int option) { this.currencyConverted = "DOLAR (US$)"; break; case 2: - this.currency = "REAL (R$)"; + this.currency = "REAL (R$)"; this.currencyConverted = "EURO (€$)"; break; case 3: - this.currency = "DOLAR (US$)"; + this.currency = "DOLAR (US$)"; this.currencyConverted = "REAL (R$)"; - break; + break; case 4: this.currency = "DOLAR (US$)"; this.currencyConverted = "EURO (€$)"; break; case 5: - this.currency = "EURO (€$)"; + this.currency = "EURO (€$)"; this.currencyConverted = "REAL (R$)"; break; case 6: - this.currency = "EURO (€$)"; + this.currency = "EURO (€$)"; this.currencyConverted = "DOLAR (US$)"; - break; + break; } } public void printConversion(double value1, double value2) { - System.out.println("==========================="); - System.out.println(" VALOR = "+value1); - System.out.println("---------------------------"); - System.out.println(" VALOR CONVERTIDO "); - System.out.print(this.currency+" = "); - System.out.printf("%.2f %n",value1); + System.out.println("========================"); + System.out.println(" VALOR = " + value1); + System.out.println("------------------------"); + System.out.println(" VALOR CONVERTIDO "); + System.out.print(this.currency + " = "); + System.out.printf("%.2f %n", value1); System.out.println(" || "); - System.out.print(this.currencyConverted+" = "); - System.out.printf("%.2f %n",value2); - System.out.println("==========================="); + System.out.print(this.currencyConverted + " = "); + System.out.printf("%.2f %n", value2); + System.out.println("========================"); } }