Commit 7404562d authored by benn.robinson's avatar benn.robinson

Update AssessmentPartFour.java

parent 2001fc96
...@@ -15,10 +15,47 @@ public class AssessmentPartFour { ...@@ -15,10 +15,47 @@ public class AssessmentPartFour {
public String translateMorse() public String translateMorse()
{ {
return "";
}
String output = "";
String [][] translateMorse = {
{".-", "a"},
{"-...", "b"},
{"-.-.", "c"},
{"-..", "d"},
{".", "e"},
{"..-.", "f"},
{"--.", "g"},
{"....", "h"},
{"..", "i"},
{".---", "j"},
{"-.-", "k"},
{".-..", "l"},
{"--", "m"},
{"-.", "n"},
{"---", "o"},
{".--.", "p"},
{"--.-", "q"},
{".-.", "r"},
{"...", "s"},
{"-", "t"},
{"..-", "u"},
{"...-", "v"},
{".--", "w"},
{"-..-", "x"},
{"-.--", "y"},
{"--..", "z"},
{"/", " "}};
for (String morse : morseCode) {
for (int i = 0; i < translateMorse.length; i++) {
if (morse.equals(translateMorse[i][0])) {
output = output + translateMorse[i][1];
break;
}
}
}
morseCode.clear();
return output;
} }
}
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