소스 검색

Merge 94d5550ed5ad8656004584fd41fd5f312a2dfaf9 into acdd71eb540bd8356719c3274bc7bbbdbd82ea21

SupaGrammer 6 년 전
부모
커밋
cb0f9a2782
No account linked to committer's email
5개의 변경된 파일63개의 추가작업 그리고 16개의 파일을 삭제
  1. 8
    0
      Crypto/src/Caesar.java
  2. 33
    15
      Crypto/src/ROT13.java
  3. 0
    1
      Crypto/src/ROT13Test.java
  4. 15
    0
      SimpleCrypt.iml
  5. 7
    0
      pom.xml

+ 8
- 0
Crypto/src/Caesar.java 파일 보기

@@ -0,0 +1,8 @@
1
+
2
+
3
+public class Caesar extends ROT13 {
4
+
5
+    Caesar(Character cs, Character cf) {
6
+        super(cs, cf);
7
+    }
8
+}

+ 33
- 15
Crypto/src/ROT13.java 파일 보기

@@ -1,8 +1,10 @@
1
+import java.util.Scanner;
2
+
1 3
 import static java.lang.Character.isLowerCase;
2 4
 import static java.lang.Character.isUpperCase;
3 5
 import static java.lang.Character.toLowerCase;
4 6
 
5
-public class ROT13  {
7
+public class ROT13 {
6 8
 
7 9
     ROT13(Character cs, Character cf) {
8 10
     }
@@ -12,21 +14,37 @@ public class ROT13  {
12 14
 
13 15
 
14 16
     public String crypt(String text) throws UnsupportedOperationException {
17
+        StringBuilder sb = new StringBuilder();
18
+        for (int i = 0; i < text.length(); i++) {
19
+            char c = text.charAt(i);
20
+            if ((c >= 'A') && (c <= 'M')) {
21
+                c += 13;
22
+            } else if ((c >= 'a') && (c <= 'm')) {
23
+                c += 13;
24
+            } else if ((c >= 'N') && (c <= 'Z')) {
25
+                c -= 13;
26
+            } else if ((c >= 'n') && (c <= 'z')) {
27
+                c -= 13;
28
+            }
29
+            sb.append(c);
30
+        }
31
+        return sb.toString();
15 32
 
16
-        return "";
17
-    }
18
-
19
-    public String encrypt(String text) {
20
-        return text;
21 33
     }
22 34
 
23
-    public String decrypt(String text) {
24
-        return text;
35
+        public String encrypt (String text){
36
+            return crypt(text);
37
+        }
38
+
39
+        public String decrypt (String text){
40
+            return crypt(text);
41
+        }
42
+
43
+        public static String rotate (String s, Character c){
44
+            int firstIndex = s.indexOf(c);
45
+            StringBuilder sb = new StringBuilder();
46
+            sb.append(s.substring(firstIndex, s.length()));
47
+            sb.append(s.substring(0, firstIndex));
48
+            return sb.toString();
49
+        }
25 50
     }
26
-
27
-    public static String rotate(String s, Character c) {
28
-
29
-        return "";
30
-    }
31
-
32
-}

+ 0
- 1
Crypto/src/ROT13Test.java 파일 보기

@@ -1,5 +1,4 @@
1 1
 import org.junit.Test;
2
-
3 2
 import static org.junit.Assert.*;
4 3
 
5 4
 public class ROT13Test {

+ 15
- 0
SimpleCrypt.iml 파일 보기

@@ -0,0 +1,15 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
3
+  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5">
4
+    <output url="file://$MODULE_DIR$/target/classes" />
5
+    <output-test url="file://$MODULE_DIR$/target/test-classes" />
6
+    <content url="file://$MODULE_DIR$">
7
+      <sourceFolder url="file://$MODULE_DIR$/Crypto/src" isTestSource="false" />
8
+      <excludeFolder url="file://$MODULE_DIR$/target" />
9
+    </content>
10
+    <orderEntry type="inheritedJdk" />
11
+    <orderEntry type="sourceFolder" forTests="false" />
12
+    <orderEntry type="library" name="Maven: junit:junit:4.12" level="project" />
13
+    <orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
14
+  </component>
15
+</module>

+ 7
- 0
pom.xml 파일 보기

@@ -7,6 +7,13 @@
7 7
     <groupId>com.zipcodewilmington</groupId>
8 8
     <artifactId>SimpleCrypt</artifactId>
9 9
     <version>1.0-SNAPSHOT</version>
10
+    <dependencies>
11
+        <dependency>
12
+            <groupId>junit</groupId>
13
+            <artifactId>junit</artifactId>
14
+            <version>RELEASE</version>
15
+        </dependency>
16
+    </dependencies>
10 17
 
11 18
 
12 19
 </project>