Browse Source

all methods written and all tests pass

Margaret Pierse 6 years ago
parent
commit
e0ef8c41aa
1 changed files with 7 additions and 2 deletions
  1. 7
    2
      LoopFun.java

+ 7
- 2
LoopFun.java View File

@@ -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
 }