package rubys.ninja.experiments.zahlenpuzzle.board;

import rubys.ninja.experiments.zahlenpuzzle.token.Token;

import java.util.List;

public class Board {
    private BoardSize size;
    private List<Token> tokens;

    public Board(BoardInitializer initializer) {
        this.size = initializer.getBoardSize();
        this.tokens = initializer.getTokens();
    }

    public Token getTokenAt(BoardSize location) throws Exception {
        return null;
    }

    public BoardSize getSize() {
        return size;
    }

    public void swapTokens(BoardSize pos1, BoardSize pos2) throws Exception {
    }
}

@@ -440,19 +440,85 @@
     
-return null
+int index = getIndexFromLocation(location);%0A%0A        return tokens.get(index)
 ;%0A  
@@ -657,20 +657,417 @@
 Exception %7B%0A
+        Token token1 = getTokenAt(pos1);%0A        Token token2 = getTokenAt(pos2);%0A%0A        int index1 = getIndexFromLocation(pos1);%0A        int index2 = getIndexFromLocation(pos2);%0A%0A        tokens.set(index1, token2);%0A        tokens.set(index2, token1);%0A    %7D%0A%0A    private int getIndexFromLocation(BoardSize location) %7B%0A        return location.getHeight() * size.getWidth() + location.getWidth();%0A
     %7D%0A%7D%0A

Implement swapTokens, getTokenAt