Skip to content

Commit ebb05f7

Browse files
committed
implemented exercise two-fer
1 parent a28010c commit ebb05f7

6 files changed

Lines changed: 74 additions & 0 deletions

File tree

‎config.json‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
"difficulty": 1,
1111
"topics": []
1212
},
13+
{
14+
"slug": "two-fer",
15+
"difficulty": 1,
16+
"topics": []
17+
},
1318
{
1419
"slug": "rna-transcription",
1520
"difficulty": 2,

‎exercises/settings.gradle‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,6 @@ include 'sum-of-multiples'
6767
include 'triangle'
6868
include 'trinary'
6969
include 'twelve-days'
70+
include 'two-fer'
7071
include 'word-count'
7172
include 'wordy'

‎exercises/two-fer/build.gradle‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
}

0 commit comments

Comments
 (0)