Permalink
Browse files

[tdd-diamond] Calculate collumn of right letters and observe that lef…

…t and right overlap for certain letters
  • Loading branch information...
michaelszymczak committed Apr 9, 2017
1 parent e65563a commit fe3bb6271db0a50b98ba411571921e3614577dd2
@@ -26,17 +26,17 @@ public String rendered() {
Layout layout = Layout.forLastLetterBeing(B);
return new Board(
new PositionedLetter(ofYX(layout.yOfTop(A),layout.xOfLeft(A)), A),
new PositionedLetter(ofYX(layout.yOfTop(B),layout.xOfLeft(B)), B), new PositionedLetter(ofYX(layout.yOfTop(B),2), B),
new PositionedLetter(ofYX(layout.yOfBottom(A),1), A)
new PositionedLetter(ofYX(layout.yOfTop(B),layout.xOfLeft(B)), B), new PositionedLetter(ofYX(layout.yOfTop(B),layout.xOfRight(B)), B),
new PositionedLetter(ofYX(layout.yOfBottom(A),layout.xOfLeft(A)), A)
).toString();
}

Layout layout = Layout.forLastLetterBeing(C);
return new Board(
new PositionedLetter(ofYX(layout.yOfTop(A),layout.xOfLeft(A)), A),
new PositionedLetter(ofYX(layout.yOfTop(B),layout.xOfLeft(B)), B), new PositionedLetter(ofYX(layout.yOfTop(B),3), B),
new PositionedLetter(ofYX(layout.yOfTop(C),layout.xOfLeft(C)), C), new PositionedLetter(ofYX(layout.yOfTop(C),4), C),
new PositionedLetter(ofYX(layout.yOfBottom(B),layout.xOfLeft(B)), B), new PositionedLetter(ofYX(layout.yOfBottom(B),3), B),
new PositionedLetter(ofYX(layout.yOfTop(B),layout.xOfLeft(B)), B), new PositionedLetter(ofYX(layout.yOfTop(B),layout.xOfRight(B)), B),
new PositionedLetter(ofYX(layout.yOfTop(C),layout.xOfLeft(C)), C), new PositionedLetter(ofYX(layout.yOfTop(C),layout.xOfRight(C)), C),
new PositionedLetter(ofYX(layout.yOfBottom(B),layout.xOfLeft(B)), B), new PositionedLetter(ofYX(layout.yOfBottom(B),layout.xOfRight(B)), B),
new PositionedLetter(ofYX(layout.yOfBottom(A),layout.xOfLeft(A)), A)
).toString();

@@ -17,11 +17,15 @@ public int yOfTop(Letter letter) {
}

public int yOfBottom(Letter letter) {
return lastLetter.ordinal() * 2 - letter.ordinal();
return lastLetter.ordinal() + lastLetter.ordinal() - letter.ordinal();
}

public int xOfLeft(Letter letter) {
return lastLetter.ordinal() - letter.ordinal();
}

public int xOfRight(Letter letter) {
return lastLetter.ordinal() + letter.ordinal();
}

}
@@ -12,11 +12,13 @@ class LayoutShould extends Specification {

def "let the top letter to be in ordinal number distance from the top"() {
given:
def layout = layout()
def layout = forLastLetterBeing(D)

expect:
layout.yOfTop(A) == 0
layout.yOfTop(B) == 1
layout.yOfTop(C) == 2
layout.yOfTop(D) == 3
}

def "let the bottom letter to be in ordinal number distance from the bottom which is twice the ordinal number of the max letter"() {
@@ -41,7 +43,14 @@ class LayoutShould extends Specification {
layout.xOfLeft(A) == 3
}

private static Layout layout() {
forLastLetterBeing(C)
def "let the right letter to be closer if their ordinal number is higher"() {
given:
def layout = forLastLetterBeing(D)

expect:
layout.xOfRight(A) == 3
layout.xOfRight(B) == 4
layout.xOfRight(C) == 5
layout.xOfRight(D) == 6
}
}

0 comments on commit fe3bb62

Please sign in to comment.