Made the translator actually work

Lncvrt made the functions in Translator.java
This commit is contained in:
Puppet committed 2025-07-25 20:13:14 -07:00
1 parent bb2d7097d7
commit f240fa5fe1
2 files changed
+143 -9

No files matched your search

+11 -9
View File
@@ -2,12 +2,8 @@ package xyz.puppet57;
import java.util.Objects; import java.util.Objects;
//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
public class Main { public class Main {
public static void main(String[] args) { public static void main(String[] args) {
//TIP Press <shortcut actionId="ShowIntentionActions"/> with your caret at the highlighted text
// to see how IntelliJ IDEA suggests fixing it.
java.util.Scanner myObj = new java.util.Scanner(System.in); // Create a Scanner object java.util.Scanner myObj = new java.util.Scanner(System.in); // Create a Scanner object
System.out.print("Se Se Lu Lu to english [E] or english to Se Se Lu Lu [S]?: "); System.out.print("Se Se Lu Lu to english [E] or english to Se Se Lu Lu [S]?: ");
@@ -16,16 +12,22 @@ public class Main {
String EtoSorStoE = myObj.nextLine(); // Read user input String EtoSorStoE = myObj.nextLine(); // Read user input
int Lang = 1; int Lang = 1;
if (Objects.equals(EtoSorStoE, "E")) { if (Objects.equals(EtoSorStoE.toLowerCase(), "e")) {
System.out.print("Type your Se Se Lu Lu: "); System.out.print("Type your Se Se Lu Lu: ");
} else if (Objects.equals(EtoSorStoE, "S")) { } else if (Objects.equals(EtoSorStoE.toLowerCase(), "s")) {
System.out.print("Type your English: "); System.out.print("Type your English: ");
Lang = 2; Lang = 2;
} }
// String Sentence = myObj.nextLine(); String Sentence = myObj.nextLine();
String ConvertedSentence;
// The replacement logic will go here if (Lang == 1) {
// Lncvrt will probably make the replacement logic ConvertedSentence = Translator.ConvertFrom(Sentence);
} else {
ConvertedSentence = Translator.ConvertTo(Sentence);
}
System.out.println("Converted sentence: " + ConvertedSentence);
} }
} }
+132
View File
@@ -0,0 +1,132 @@
package xyz.puppet57;
public class Translator {
public static String ConvertTo(String input) {
StringBuilder sb = new StringBuilder();
for (char c : input.toCharArray()) {
String mapped = switch (c) {
case 'a' -> "selu";
case 'b' -> "seselulu";
case 'c' -> "seseselululu";
case 'd' -> "dedecucu";
case 'e' -> "lalalulu";
case 'f' -> "fafu";
case 'g' -> "googoogaagaa";
case 'h' -> "hahaha";
case 'i' -> "eiei";
case 'j' -> "jaja";
case 'k' -> "ok";
case 'l' -> "lagu";
case 'm' -> "moo";
case 'n' -> "no";
case 'o' -> "oogabooga";
case 'p' -> "pepe";
case 'q' -> "oogalyboogaly";
case 'r' -> "rahroo";
case 's' -> "solay";
case 't' -> "tootay";
case 'u' -> "yala";
case 'v' -> "vooloo";
case 'w' -> "waawaa";
case 'x' -> "tumtum";
case 'y' -> "yumyum";
case 'z' -> "zooloola";
case 'A' -> "SELU";
case 'B' -> "SESELULU";
case 'C' -> "SESESELULULU";
case 'D' -> "DEDECUCU";
case 'E' -> "LALALULU";
case 'F' -> "FAFU";
case 'G' -> "GOOGOOGAAGAA";
case 'H' -> "HAHAHA";
case 'I' -> "EIEI";
case 'J' -> "JAJA";
case 'K' -> "OK";
case 'L' -> "LAGU";
case 'M' -> "MOO";
case 'N' -> "NO";
case 'O' -> "OOGABOOGA";
case 'P' -> "PEPE";
case 'Q' -> "OOGALYBOOGALY";
case 'R' -> "RAHROO";
case 'S' -> "SOLAY";
case 'T' -> "TOOTAY";
case 'U' -> "YALA";
case 'V' -> "VOOLOO";
case 'W' -> "WAAWAA";
case 'X' -> "TUMTUM";
case 'Y' -> "YUMYUM";
case 'Z' -> "ZOOLOOLA";
default -> "";
};
if (!mapped.isEmpty()) {
if (!sb.isEmpty()) sb.append(' ');
sb.append(mapped);
}
}
return sb.toString();
}
public static String ConvertFrom(String input) {
StringBuilder sb = new StringBuilder();
for (String word : input.split(" ")) {
char mapped = switch (word) {
case "selu" -> 'a';
case "seselulu" -> 'b';
case "seseselululu" -> 'c';
case "dedecucu" -> 'd';
case "lalalulu" -> 'e';
case "fafu" -> 'f';
case "googoogaagaa" -> 'g';
case "hahaha" -> 'h';
case "eiei" -> 'i';
case "jaja" -> 'j';
case "ok" -> 'k';
case "lagu" -> 'l';
case "moo" -> 'm';
case "no" -> 'n';
case "oogabooga" -> 'o';
case "pepe" -> 'p';
case "oogalyboogaly" -> 'q';
case "rahroo" -> 'r';
case "solay" -> 's';
case "tootay" -> 't';
case "yala" -> 'u';
case "vooloo" -> 'v';
case "waawaa" -> 'w';
case "tumtum" -> 'x';
case "yumyum" -> 'y';
case "zooloola" -> 'z';
case "SELU" -> 'A';
case "SESELULU" -> 'B';
case "SESESELULULU" -> 'C';
case "DEDECUCU" -> 'D';
case "LALALULU" -> 'E';
case "FAFU" -> 'F';
case "GOOGOOGAAGAA" -> 'G';
case "HAHAHA" -> 'H';
case "EIEI" -> 'I';
case "JAJA" -> 'J';
case "OK" -> 'K';
case "LAGU" -> 'L';
case "MOO" -> 'M';
case "NO" -> 'N';
case "OOGABOOGA" -> 'O';
case "PEPE" -> 'P';
case "OOGALYBOOGALY" -> 'Q';
case "RAHROO" -> 'R';
case "SOLAY" -> 'S';
case "TOOTAY" -> 'T';
case "YALA" -> 'U';
case "VOOLOO" -> 'V';
case "WAAWAA" -> 'W';
case "TUMTUM" -> 'X';
case "YUMYUM" -> 'Y';
case "ZOOLOOLA" -> 'Z';
default -> '\0';
};
if (mapped != '\0') sb.append(mapped);
}
return sb.toString();
}
}