-
Notifications
You must be signed in to change notification settings - Fork 1
/
Morse_IP.java
51 lines (34 loc) · 963 Bytes
/
Morse_IP.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import java.io.*;
import java.util.*;
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.HashMap;
import java.util.Random;
import java.net.URL;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map.Entry;
import java.util.Iterator;
import java.util.prefs.Preferences;
import java.util.Hashtable;
import java.awt.*;
public class Morse_IP extends Main {
int n;
public String code_decode(String morse) {
String[] morse_arr = morse.split(" ");
String n[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "."};
String b[] = {"_____", ".____", "..___", "...__", "...._", ".....", "_....", "__...", "___..", "____.", "..."};
String decoded = "";
for (int i=0; i<morse_arr.length; i++) {
String z = morse_arr[i];
for (int j=0; j<11; j++) {
if (z.equals(b[j])) {
decoded = decoded + n[j];
}
}
}
return decoded;
}
}