瀏覽代碼

added reverse string exercise to track

Brandon Kiefer 8 年之前
父節點
當前提交
93497625d9

+ 10
- 0
config.json 查看文件

@@ -13,6 +13,16 @@
13 13
       "uuid": "f77dc7e3-35a8-4300-a7c8-2c1765e9644d"
14 14
     },
15 15
     {
16
+      "core": false,
17
+      "difficulty": 1,
18
+      "slug": "reverse-string",
19
+      "topics": [
20
+        "strings"
21
+      ],
22
+      "unlocked_by": null,
23
+      "uuid": "2c8afeed-480e-41f3-ad58-590fa8f88029"
24
+    },
25
+    {
16 26
       "core": true,
17 27
       "difficulty": 1,
18 28
       "slug": "two-fer",

+ 7
- 0
exercises/reverse-string/.meta/src/reference/java/ReverseString.java 查看文件

@@ -0,0 +1,7 @@
1
+class ReverseString {
2
+  
3
+    String reverse(String inputString) {
4
+        return new StringBuffer(inputString).reverse().toString();
5
+    }
6
+  
7
+}

+ 1
- 0
exercises/reverse-string/.meta/version 查看文件

@@ -0,0 +1 @@
1
+1.0.1

+ 17
- 0
exercises/reverse-string/README.md 查看文件

@@ -0,0 +1,17 @@
1
+# Reverse String
2
+
3
+For example: input: "cool" output: "looc"
4
+
5
+# Running the tests
6
+
7
+You can run all the tests for an exercise by entering
8
+
9
+```sh
10
+$ gradle test
11
+```
12
+
13
+in your terminal.
14
+
15
+## Submitting Incomplete Solutions
16
+
17
+It's possible to submit an incomplete solution so you can see how others have completed the exercise.

+ 17
- 0
exercises/reverse-string/build.gradle 查看文件

@@ -0,0 +1,17 @@
1
+apply plugin: "java"
2
+apply plugin: "eclipse"
3
+apply plugin: "idea"
4
+
5
+repositories {
6
+    mavenCentral()
7
+}
8
+
9
+dependencies {
10
+    testCompile "junit:junit:4.12"
11
+}
12
+test {
13
+    testLogging {
14
+        exceptionFormat = 'full'
15
+        events = ["passed", "failed", "skipped"]
16
+    }
17
+}

+ 7
- 0
exercises/reverse-string/src/main/java/ReverseString.java 查看文件

@@ -0,0 +1,7 @@
1
+class ReverseString {
2
+  
3
+    String reverse() {
4
+        throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
5
+    }
6
+  
7
+}

+ 37
- 0
exercises/reverse-string/src/test/java/ReverseStringTest.java 查看文件

@@ -0,0 +1,37 @@
1
+import org.junit.Ignore;
2
+import org.junit.Test;
3
+
4
+import static org.junit.Assert.assertEquals;
5
+
6
+public class ReverseStringTest {
7
+
8
+    @Test
9
+    public void testAnEmptyString() {
10
+        assertEquals("", new ReverseString().reverse(""));
11
+    }
12
+
13
+    @Ignore("Remove to run test")
14
+    @Test
15
+    public void testAWord() {
16
+        assertEquals("tobor", new ReverseString().reverse("robot"));
17
+    }
18
+
19
+    @Ignore("Remove to run test")
20
+    @Test
21
+    public void testACapitalizedWord() {
22
+        assertEquals("nemaR", new ReverseString().reverse("Ramen"));
23
+    }
24
+
25
+    @Ignore("Remove to run test")
26
+    @Test
27
+    public void testASentenceWithPunctuation() {
28
+        assertEquals("!yrgnuh m'I", new ReverseString().reverse("I'm hungry!"));
29
+    }
30
+
31
+    @Ignore("Remove to run test")
32
+    @Test
33
+    public void testAPalindrome() {
34
+        assertEquals("racecar", new ReverseString().reverse("racecar"));
35
+    }
36
+
37
+}

+ 1
- 0
exercises/settings.gradle 查看文件

@@ -59,6 +59,7 @@ include 'pythagorean-triplet'
59 59
 include 'queen-attack'
60 60
 include 'raindrops'
61 61
 include 'rectangles'
62
+include 'reverse-string'
62 63
 include 'rna-transcription'
63 64
 include 'robot-name'
64 65
 include 'robot-simulator'