Commit 57fce6ea authored by m.baxter's avatar m.baxter

Basic skeleton of the code.

parent d31faef9
...@@ -13,18 +13,23 @@ public class Main { ...@@ -13,18 +13,23 @@ public class Main {
int menuSelect; int menuSelect;
Scanner scan = new Scanner(System.in); Scanner scan = new Scanner(System.in);
menuSelect = scan.nextInt(); menuSelect = scan.nextInt();
scan.close();
HashMap<Character,String> codes = new HashMap<Character,String>(); HashMap<Character,String> map = new HashMap<Character,String>();
map = Morse.initialise(map);
switch(menuSelect) { switch(menuSelect) {
case 1: case 1:
// Convert from English to morse // Get user input and then convert from English to morse
break; break;
case 2: case 2:
// Convert morse to English. // Get user input and then convert morse to English.
break; break;
case 3:
// Print the contents of the map
Morse.printMap(map);
} }
} }
......
...@@ -4,12 +4,64 @@ import java.util.HashMap; ...@@ -4,12 +4,64 @@ import java.util.HashMap;
public class Morse { public class Morse {
// Set up a map with all of the morse code values mapped.
public static HashMap<Character,String> initialise(HashMap<Character,String> map) { public static HashMap<Character,String> initialise(HashMap<Character,String> map) {
map.put('a', "101110");
map.put('a', "10111"); map.put('b', "1110101010");
map.put('c', "111010111010");
map.put('d', "11101010");
map.put('e', "10");
map.put('f', "1010111010");
map.put('g', "1110111010");
map.put('h', "10101010");
map.put('i', "1010");
map.put('j', "10111011101110");
map.put('k', "1110101110");
map.put('l', "1011101010");
map.put('m', "11101110");
map.put('n', "111010");
map.put('o', "111011101110");
map.put('p', "101110111010");
map.put('q', "11101110101110");
map.put('r', "10111010");
map.put('s', "101010");
map.put('t', "1110");
map.put('u', "10101110");
map.put('v', "1010101110");
map.put('w', "1011101110");
map.put('x', "111010101110");
map.put('y', "11101011101110");
map.put('z', "111011101010");
map.put('0', "11101110111011101110");
map.put('1', "101110111011101110");
map.put('2', "1010111011101110");
map.put('3', "10101011101110");
map.put('4', "101010101110");
map.put('5', "1010101010");
map.put('6', "111010101010");
map.put('7', "11101110101010");
map.put('8', "1110111011101010");
map.put('9', "111011101110111010");
return map; return map;
} }
// Turn a string of morse code characters into a sentence
public static String morseToEng(String sentance, HashMap<Character, String> map) {
return;
}
// Turn a string of English into morse code
public static String engToMorse(String sentance, HashMap<Character, String> map) {
return;
}
// Loop through the map and print it
public static void printMap(HashMap<Character, String> map) {
// Loop through the map
for(Character letter : map.keySet()) {
System.out.println("Letter: " + letter + " Value: " + map.get(letter));
}
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment