Finalizado
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/target/
|
||||
@@ -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";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user