Browse Source

implemented exercise two-fer

Smarticles101 9 years ago
parent
commit
ebb05f74e9

+ 5
- 0
config.json View File

@@ -11,6 +11,11 @@
11 11
       "topics": []
12 12
     },
13 13
     {
14
+      "slug": "two-fer",
15
+      "difficulty": 1,
16
+      "topics": []
17
+    },
18
+    {
14 19
       "slug": "rna-transcription",
15 20
       "difficulty": 2,
16 21
       "topics": []

+ 1
- 0
exercises/settings.gradle View File

@@ -67,5 +67,6 @@ include 'sum-of-multiples'
67 67
 include 'triangle'
68 68
 include 'trinary'
69 69
 include 'twelve-days'
70
+include 'two-fer'
70 71
 include 'word-count'
71 72
 include 'wordy'

+ 17
- 0
exercises/two-fer/build.gradle View File

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

+ 5
- 0
exercises/two-fer/src/example/java/Twofer.java View File

@@ -0,0 +1,5 @@
1
+public class Twofer {
2
+    public String twofer(String name) {
3
+        return "One for " + (name != null ? name : "you") + ", one for me.";
4
+    }
5
+}

+ 5
- 0
exercises/two-fer/src/main/java/Twofer.java View File

@@ -0,0 +1,5 @@
1
+public class Twofer {
2
+    public String twofer(String name) {
3
+        throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
4
+    }
5
+}

+ 41
- 0
exercises/two-fer/src/test/java/TwoferTest.java View File

@@ -0,0 +1,41 @@
1
+import org.junit.Before;
2
+import org.junit.Ignore;
3
+import org.junit.Test;
4
+
5
+import static org.junit.Assert.assertEquals;
6
+
7
+public class TwoferTest {
8
+
9
+    private Twofer twofer;
10
+
11
+    @Before
12
+    public void setup() {
13
+        twofer = new Twofer();
14
+    }
15
+
16
+    @Test
17
+    public void noNameGiven() {
18
+        String input = null;
19
+        String expected = "One for you, one for me.";
20
+
21
+        assertEquals(expected, twofer.twofer(input));
22
+    }
23
+
24
+    @Test
25
+    @Ignore("Remove to run test")
26
+    public void aNameGiven() {
27
+        String input = "Alice";
28
+        String expected = "One for Alice, one for me.";
29
+
30
+        assertEquals(expected, twofer.twofer(input));
31
+    }
32
+
33
+    @Test
34
+    @Ignore("Remove to run test")
35
+    public void anotherNameGiven() {
36
+        String input = "Bob";
37
+        String expected = "One for Bob, one for me.";
38
+
39
+        assertEquals(expected, twofer.twofer(input));
40
+    }
41
+}