Skip to content

Commit

Permalink
[tdd-diamond] Letter is enum
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelszymczak committed Apr 9, 2017
1 parent 8df0bc2 commit 0d65319
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@


public class Diamond { public class Diamond {


private char letter; private Letter letter;


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


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


public String rendered() { public String rendered() {
return letter == 'A' ? "A" : " A \nB B\n A "; return letter == Letter.A ? "A" : " A \nB B\n A ";
} }
} }
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.michaelszymczak.diamond;

public enum Letter {
A, B
}
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ class DiamondAcceptanceTest extends Specification {


def "contains one letter if it is the first letter"() { def "contains one letter if it is the first letter"() {
expect: expect:
Diamond.of('A' as char).rendered() == "A" Diamond.of(Letter.A).rendered() == "A"
} }


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

" A "
} }
} }

0 comments on commit 0d65319

Please sign in to comment.