Permalink
Browse files

[tdd-diamond] Diamond of B

  • Loading branch information...
michaelszymczak committed Apr 9, 2017
1 parent bfb5ecf commit 8df0bc226c04bd34b968cff4c37676670ab0b929
@@ -1,11 +1,18 @@
package com.michaelszymczak.diamond;

public class Diamond {

private char letter;

public static Diamond of(char letter) {
return new Diamond();
return new Diamond(letter);
}

private Diamond(char letter) {
this.letter = letter;
}

public String rendered() {
return "A";
return letter == 'A' ? "A" : " A \nB B\n A ";
}
}
@@ -8,4 +8,12 @@ class DiamondAcceptanceTest extends Specification {
expect:
Diamond.of('A' as char).rendered() == "A"
}

def "creates diamond shape if more than one letter"() {
expect:
Diamond.of('B' as char).rendered() == " A " + "\n" +
"B B" + "\n" +
" A "

}
}

0 comments on commit 8df0bc2

Please sign in to comment.