Commit f00759ce authored by ash.brett's avatar ash.brett

Update AssessmentPartFour.java

parent 412b1286
...@@ -66,15 +66,15 @@ public class AssessmentPartFour { ...@@ -66,15 +66,15 @@ public class AssessmentPartFour {
//This is a new method that I created that takes in the string Morse //This is a new method that I created that takes in the string Morse
public String MorseToEnglish(String Morse) { public String MorseToEnglish(String Morse) {
//This is where I create two strings one called alpha containing the English alphabet and the other called morse which contains the morse equivalents //This is where I create two strings one called alphabet containing the english alphabet and the other called morse which contains the morse equivalents
String[] alpha = {"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", " "}; String[] alphabet = {"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", " "};
String[] morse = {".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..",".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-","...-" ,".--" ,"-..-", "-.--", "--..", "/"}; String[] morse = {".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..",".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-","...-" ,".--" ,"-..-", "-.--", "--..", "/"};
//This section of code creates the int i and sets it to 0. it then states that for each time i is less than morse's length increment it by one and then run the code below //This section of code creates the int i and sets it to 0. it then states that for each time i is less than morse's length increment it by one and then run the code below
for(int i = 0; i < morse.length; ++i){ for(int i = 0; i < morse.length; ++i){
//This section of code compares the string Morse to the String morse based on the value of i //This section of code compares the string Morse to the String morse based on the value of i
if(Morse.equals(morse[i])) { if(Morse.equals(morse[i])) {
//This section of code returns the alpha value of morse if they both match //This section of code returns the alphabet value of morse if they both match
return alpha[i]; return alphabet[i];
} }
} }
...@@ -88,4 +88,5 @@ public class AssessmentPartFour { ...@@ -88,4 +88,5 @@ public class AssessmentPartFour {
}
} }
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