Commit 1cbc0815 authored by neil.whitehead's avatar neil.whitehead

12:03 18/12/18

parent bdbea1a8
......@@ -37,9 +37,7 @@ public class AssessmentPartFour
catch (IOException e)
{
System.out.println("error");
}
System.out.println(filename + " " + morseCode.size());
}
return morseCode.size();
}
......@@ -48,19 +46,50 @@ public class AssessmentPartFour
public String translateMorse()
{
System.out.println("translate");
System.out.println(morseCode.size());
System.out.println(morseCode.get(0));
{
for(int i = 0; i < morseCode.size(); i++)
{
System.out.println(morseCode.get(i));
System.out.println(morseCode.get(i) + " " + (morseCode.get(i)).length());
}
String strTranslated = "strTranslated ";
String[][] strMorseArray =
{{" ", "E", "T"}, // have 1 char
{"/", ".", "-"},
{"A", "I", "N", "M"}, // have 2 char
{".-", "..", "-.", "--"},
{"D", "G", "K", "O", "R", "S", "U", "W"}, // have 3 char
{"-..", "--.", "-.-", "---", ".-.", "...", "..-", ".--"},
{"B", "C", "F", "H", "J", "L", "P", "Q", "V", "X", "Y", "Z"}, // have 4 char
{"-...", "-.-.", "..-.", "....", ".---", ".-..", ".--.", "--.-", "..._", "-..-", "-.--", "--.."},
{"1", "2", "3", "4", "5", "6", "7", "8", "9", "0"}, // have 5 char
{".----", "..---", "...--", "....-", ".....", "-....", "--...", "---..", "----.", "-----"}};
for(int i = 0; i < morseCode.size(); i++)
{
int x = (((morseCode.get(i)).length()) * 2) - 1;
for(int y = 0; y < strMorseArray[x].length; y++)
{
System.out.println("something");
System.out.println(strMorseArray[x-1][y]);
if(strMorseArray[x][y].contains(morseCode.get(i)))
{
strTranslated.concat(strMorseArray[x-1][y]);
strMorseArray[x-1][y].concat(strTranslated);
break;
}
}
}
//NEED TO SORT OUT LOOPS. WHY HAVE I DIVIDED THE MORSE ARRAY LIKE THIS AGAIN? WHY AREN'T MY STRINGS CONCATNATING?
System.out.println(strTranslated);
return "";
}
......
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