From 2c6e0ce2c71f2a395b110ebbffe7b5198bffc3d1 Mon Sep 17 00:00:00 2001 From: Adam NAILI Date: Sun, 14 Jan 2018 00:08:43 +0100 Subject: Updating documentation and formatting BoardConverter --- src/main/java/fr/umlv/java/wallj/board/BoardConverter.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/main/java/fr/umlv') diff --git a/src/main/java/fr/umlv/java/wallj/board/BoardConverter.java b/src/main/java/fr/umlv/java/wallj/board/BoardConverter.java index 6231875..c4d47cc 100644 --- a/src/main/java/fr/umlv/java/wallj/board/BoardConverter.java +++ b/src/main/java/fr/umlv/java/wallj/board/BoardConverter.java @@ -6,13 +6,17 @@ import java.util.ArrayList; import java.util.List; /** + * Operations of conversion on Board and List of blocks * @author Adam NAILI */ public final class BoardConverter { - //TODO private BoardConverter() { } + /** + * @param blocks the list of blocks to convert in a board + * @return the converted board + */ public static Board worldToBoard(List blocks) { int width = blocks.stream().map(Block::getTile).mapToInt(TileVec2::getCol).max().orElse(-1) + 1; int height = blocks.stream().map(Block::getTile).mapToInt(TileVec2::getRow).max().orElse(-1) + 1; @@ -24,6 +28,10 @@ public final class BoardConverter { return builder.build(); } + /** + * @param board the board to convert into a list of blocks + * @return the list of blocks converted + */ public static List boardToWorld(Board board) { ArrayList blocks = new ArrayList<>(); int nbRow = board.getDim().getRow(); @@ -31,7 +39,7 @@ public final class BoardConverter { for (int i = 0; i < nbRow; i++) { for (int j = 0; j < nbCol; j++) { Block block; - TileVec2 location = TileVec2.of(j,i); + TileVec2 location = TileVec2.of(j, i); block = BlockFactory.build(board.getBlockTypeAt(location), location); if (block != null) { blocks.add(block); -- cgit v1.2.3