skip to main content

kiesler.at

Morsecode mit Hashtable entschlüsseln
updated by rck, 2006-03-25

Aufgabe 4108 von der EPROG-Beispielsammlung handelt vom Entschlüsseln von MORSE-Code. Das ist was praktisches, Morse Code eignet sich zB auch zum unerkannten Lösungsdurchfunken bei Prüfungen.

1 | 2 | 3 | 4 | 5 | 6 | 7 | 8

morsen/Translate.java

1 /*      translate.java, teil von package morsen
2  *
3  *      Lösung zu http://eprog.sourceforge.net/eprog/4108/morsen.html
4  *      (Entschlüsseln von Morsecode) zu Übungszwecken
5  *
6  *      (c) 2004-09-12 http://www.kiesler.at/
7  */
8 
9 
10 package morsen;
11 
12 
13 import java.util.Hashtable;
14 
15 
16 public class Translate extends Hashtable{
17 
18         
19         public Translate() {
20 
21                 super();
22 
23                 this.put(".-.-.-",      ".");
24                 this.put("--..--",      ",");
25                 this.put("..--..",      "?");
26                 this.put("---...",      ":");
27 
28                 this.put(".-",          "A");
29                 this.put("-...",        "B");
30                 this.put("-.-.",        "C");
31                 this.put("-..",         "D");
32                 this.put(".",           "E");
33                 this.put("..-.",        "F");
34                 this.put("--.",         "G");
35                 this.put("....",        "H");
36                 this.put("..",          "I");
37                 this.put(".---",        "J");
38                 this.put("-.-",         "K");
39                 this.put(".-..",        "L");
40                 this.put("--",          "M");
41                 this.put("-.",          "N");
42                 this.put("---",         "O");
43                 this.put(".--.",        "P");
44                 this.put("--.-",        "Q");
45                 this.put(".-.",         "R");
46                 this.put("...",         "S");
47                 this.put("-",           "T");
48                 this.put("..-",         "U");
49                 this.put("...-",        "V");
50                 this.put(".--",         "W");
51                 this.put("-..-",        "X");
52                 this.put("-.--",        "Y");
53                 this.put("--..",        "Z");
54 
55                 this.put(".----",       "1");
56                 this.put("..---",       "2");
57                 this.put("...--",       "3");
58                 this.put("....-",       "4");
59                 this.put(".....",       "5");
60                 this.put("-....",       "6");
61                 this.put("--...",       "7");
62                 this.put("---..",       "8");
63                 this.put("----.",       "9");
64                 this.put("-----",       "0");
65 
66         }
67 
68 }
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8



RSSComments - Make a comment
The comments are owned by the poster. We are not responsible for its content.
RSSAll Articles
2008, 2007, 2006, 2005, 2004