Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void actionPerformed2(ActionEvent f) {
- String palabra = interfaz.getTexto1();
- String conversion2 = convertidor.convertirTextoMorse(palabra);
- interfaz.settextoMorse(conversion2);
- }
- private void actionListener2(ActionListener f) {
- interfaz.btnTexto.addActionListener(f);
- }
- public class Convertidor {
- public String convertirTextoMorse(String palabra) {
- String morse[] = { ".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", // a-i
- ".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", // j-q
- ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--..", ".......", // r-" "
- ".-", "-...", "-.-.", "-..", ".", "..-.", "--.", // A-G
- "....", "..", ".---", "-.-", ".-..", "--", "-.", "---", ".--.", // H-P
- "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", // Q-X
- "-.--", "--..", "......." }; // Y-Z
- String abecedario = (String) "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ";
- int posicion = 0;
- String conversion = "";
- for (int f = 0; f < palabra.length(); f++) {
- posicion = abecedario.indexOf(palabra.charAt(f));
- conversion = conversion + morse[posicion] + " ";
- }
- return conversion;
- }
Add Comment
Please, Sign In to add comment