From 2fb44a5eacf3c15cdbb4a8227adf9465847fbace Mon Sep 17 00:00:00 2001 From: 250405 <250405@localhost> Date: Fri, 13 Mar 2026 13:56:55 +0000 Subject: [PATCH] Finalizado --- .gitignore | 1 + .../botsencrypter/BotsEncrypter.java | 89 ++++++++++++++++++- 2 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b83d222 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/src/main/java/com/mycompany/botsencrypter/BotsEncrypter.java b/src/main/java/com/mycompany/botsencrypter/BotsEncrypter.java index 8afce9d..2e3a218 100644 --- a/src/main/java/com/mycompany/botsencrypter/BotsEncrypter.java +++ b/src/main/java/com/mycompany/botsencrypter/BotsEncrypter.java @@ -13,10 +13,12 @@ public class BotsEncrypter { boolean rodando = true; while(rodando == true){ + System.out.println("---------------------------"); System.out.println("Selecione uma das opções:\n" + "1- Encriptar\n" + "2- Decodificar\n" + "3- Sair"); + System.out.println("---------------------------"); int opcaoS = scn.nextInt(); scn.nextLine(); switch(opcaoS){ @@ -27,9 +29,92 @@ public class BotsEncrypter { } } private static String Encoder(){ - return "nada"; + Scanner scn = new Scanner(System.in); + System.out.println("Introduza a frase:"); + String input = scn.nextLine(); + int contador = 0; + String encodedword[] = new String[input.length()]; + for (int i = 0; i < input.length(); i++) { + switch(input.charAt(i)){ + case 'a' -> encodedword[i] = "0"; + case 'b' -> encodedword[i] = "1"; + case 'c' -> encodedword[i] = "2"; + case 'd' -> encodedword[i] = "3"; + case 'e' -> encodedword[i] = "4"; + case 'f' -> encodedword[i] = "5"; + case 'g' -> encodedword[i] = "6"; + case 'h' -> encodedword[i] = "7"; + case 'i' -> encodedword[i] = "8"; + case 'j' -> encodedword[i] = "9"; + case 'k' -> encodedword[i] = "p"; + case 'l' -> encodedword[i] = "o"; + case 'm' -> encodedword[i] = "n"; + case 'n' -> encodedword[i] = "m"; + case 'o' -> encodedword[i] = "l"; + case 'p' -> encodedword[i] = "k"; + case 'q' -> encodedword[i] = "j"; + case 'r' -> encodedword[i] = "i"; + case 's' -> encodedword[i] = "h"; + case 't' -> encodedword[i] = "g"; + case 'u' -> encodedword[i] = "f"; + case 'v' -> encodedword[i] = "e"; + case 'w' -> encodedword[i] = "d"; + case 'x' -> encodedword[i] = "c"; + case 'y' -> encodedword[i] = "b"; + case 'z' -> encodedword[i] = "a"; + case ' ' -> encodedword[i] = "-"; + default -> encodedword[i] = "!"; + } + } + System.out.println("---------Resultado---------"); + for (int i = 0; i < encodedword.length; i++) { + System.out.print(encodedword[i]); + } + System.out.println("\n---------------------------"); + return "finalizado"; } private static String Decoder(){ - return "nada"; + Scanner scn = new Scanner(System.in); + System.out.println("Introduza a frase:"); + String input = scn.nextLine(); + String decodedword[] = new String[input.length()]; + for (int i = 0; i < input.length(); i++) { + switch(input.charAt(i)){ + case '0' -> decodedword[i] = "a"; + case '1' -> decodedword[i] = "b"; + case '2' -> decodedword[i] = "c"; + case '3' -> decodedword[i] = "d"; + case '4' -> decodedword[i] = "e"; + case '5' -> decodedword[i] = "f"; + case '6' -> decodedword[i] = "g"; + case '7' -> decodedword[i] = "h"; + case '8' -> decodedword[i] = "i"; + case '9' -> decodedword[i] = "j"; + case 'p' -> decodedword[i] = "k"; + case 'o' -> decodedword[i] = "l"; + case 'n' -> decodedword[i] = "m"; + case 'm' -> decodedword[i] = "n"; + case 'l' -> decodedword[i] = "o"; + case 'k' -> decodedword[i] = "p"; + case 'j' -> decodedword[i] = "q"; + case 'i' -> decodedword[i] = "r"; + case 'h' -> decodedword[i] = "s"; + case 'g' -> decodedword[i] = "t"; + case 'f' -> decodedword[i] = "u"; + case 'e' -> decodedword[i] = "v"; + case 'd' -> decodedword[i] = "w"; + case 'c' -> decodedword[i] = "x"; + case 'b' -> decodedword[i] = "y"; + case 'a' -> decodedword[i] = "z"; + case '-' -> decodedword[i] = " "; + default -> decodedword[i] = "?"; + } + } + System.out.println("---------Resultado---------"); + for (int i = 0; i < decodedword.length; i++) { + System.out.print(decodedword[i]); + } + System.out.println("\n---------------------------"); + return "finalizado"; } }