Permalink
Browse files

[tdd-diamond] Refactor: mention all four positions for each letter an…

…d observe that it does not change the output as they overlap
  • Loading branch information...
michaelszymczak committed Apr 9, 2017
1 parent fe3bb62 commit 52368faedd3e9973c7de2da5f980386a080cc2e3
Showing with 27 additions and 7 deletions.
  1. +27 −7 tdd-diamond/src/main/java/com/michaelszymczak/diamond/Diamond.java
@@ -19,25 +19,45 @@ public String rendered() {
if (letter == A)
{
Layout layout = Layout.forLastLetterBeing(A);
return new Board(new PositionedLetter(ofYX(layout.yOfTop(A),layout.xOfLeft(A)), A)).toString();
return new Board(
new PositionedLetter(ofYX(layout.yOfTop(A),layout.xOfLeft(A)), A),
new PositionedLetter(ofYX(layout.yOfTop(A),layout.xOfRight(A)), A),
new PositionedLetter(ofYX(layout.yOfBottom(A),layout.xOfLeft(A)), A),
new PositionedLetter(ofYX(layout.yOfBottom(A),layout.xOfRight(A)), A)
).toString();
}
if (letter == B)
{
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),layout.xOfRight(B)), B),
new PositionedLetter(ofYX(layout.yOfBottom(A),layout.xOfLeft(A)), A)
new PositionedLetter(ofYX(layout.yOfTop(A),layout.xOfRight(A)), A),
new PositionedLetter(ofYX(layout.yOfBottom(A),layout.xOfLeft(A)), A),
new PositionedLetter(ofYX(layout.yOfBottom(A),layout.xOfRight(A)), 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(B),layout.xOfLeft(B)), B),
new PositionedLetter(ofYX(layout.yOfBottom(B),layout.xOfRight(B)), B)
).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),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)
new PositionedLetter(ofYX(layout.yOfTop(A),layout.xOfRight(A)), A),
new PositionedLetter(ofYX(layout.yOfBottom(A),layout.xOfLeft(A)), A),
new PositionedLetter(ofYX(layout.yOfBottom(A),layout.xOfRight(A)), 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(B),layout.xOfLeft(B)), B),
new PositionedLetter(ofYX(layout.yOfBottom(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(C),layout.xOfLeft(C)), C),
new PositionedLetter(ofYX(layout.yOfBottom(C),layout.xOfRight(C)), C)
).toString();

}

0 comments on commit 52368fa

Please sign in to comment.