Permalink
Browse files

[tdd-diamond] Letter is enum

  • Loading branch information...
michaelszymczak committed Apr 9, 2017
1 parent 8df0bc2 commit 0d65319b95ed24d9d62f38d9a91776acc71423cd
@@ -2,17 +2,17 @@

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);
}

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

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

public enum Letter {
A, B
}
@@ -6,14 +6,14 @@ class DiamondAcceptanceTest extends Specification {

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

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

Diamond.of(Letter.B).rendered() == "" +
" A " + "\n" +
"B B" + "\n" +
" A "
}
}

0 comments on commit 0d65319

Please sign in to comment.