Navigation Menu

Skip to content

Commit

Permalink
[tdd-diamond] Diamond of B
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelszymczak committed Apr 9, 2017
1 parent bfb5ecf commit 8df0bc2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
@@ -1,11 +1,18 @@
package com.michaelszymczak.diamond; package com.michaelszymczak.diamond;


public class Diamond { public class Diamond {

private char letter;

public static Diamond of(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() { public String rendered() {
return "A"; return letter == 'A' ? "A" : " A \nB B\n A ";
} }
} }
Expand Up @@ -8,4 +8,12 @@ class DiamondAcceptanceTest extends Specification {
expect: expect:
Diamond.of('A' as char).rendered() == "A" 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.