|
@@ -32,7 +32,6 @@ public class LoopFun
|
32
|
32
|
result = result + phrase.substring(firstSpaceIndex+1, firstSpaceIndex+2);
|
33
|
33
|
phrase = phrase.substring(0,firstSpaceIndex) + phrase.substring(firstSpaceIndex+1);
|
34
|
34
|
firstSpaceIndex = phrase.indexOf(" ");
|
35
|
|
- System.out.print(result);
|
36
|
35
|
}
|
37
|
36
|
return result;
|
38
|
37
|
}
|
|
@@ -50,6 +49,12 @@ public class LoopFun
|
50
|
49
|
* @return the encrypted string by shifting each character by three character
|
51
|
50
|
*/
|
52
|
51
|
public String encrypt(String word) {
|
53
|
|
- return null;
|
|
52
|
+ String alphabet = "abcdefghijklmnopqrstuvwxyzabcde";
|
|
53
|
+ String codedWord = "";
|
|
54
|
+ for (int i=0; i<word.length(); i++) {
|
|
55
|
+ int alphaIndex = alphabet.indexOf(word.charAt(i));
|
|
56
|
+ codedWord += String.valueOf(alphabet.charAt(alphaIndex+3));
|
|
57
|
+ }
|
|
58
|
+ return codedWord;
|
54
|
59
|
}
|
55
|
60
|
}
|