aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpacien2018-01-10 18:49:04 +0100
committerpacien2018-01-10 18:49:19 +0100
commit6ec0bbf3b3ca7e724430fd6037dfd6e2f1b9b983 (patch)
tree98d3997a997831cbac2bf9d22e03a00f56c81374 /src
parent4bf5d236f8e0a677643fd551dc605753d3646309 (diff)
downloadwallj-6ec0bbf3b3ca7e724430fd6037dfd6e2f1b9b983.tar.gz
Document more
Signed-off-by: pacien <pacien.trangirard@pacien.net>
Diffstat (limited to 'src')
-rw-r--r--src/main/java/fr/umlv/java/wallj/board/Board.java2
-rw-r--r--src/main/java/fr/umlv/java/wallj/board/BoardParser.java14
-rw-r--r--src/main/java/fr/umlv/java/wallj/board/TileVec2.java2
-rw-r--r--src/main/java/fr/umlv/java/wallj/utils/Matrix.java2
-rw-r--r--src/test/java/fr/umlv/java/wallj/board/BoardParserTest.java5
5 files changed, 23 insertions, 2 deletions
diff --git a/src/main/java/fr/umlv/java/wallj/board/Board.java b/src/main/java/fr/umlv/java/wallj/board/Board.java
index fbe6ad9..c697cc2 100644
--- a/src/main/java/fr/umlv/java/wallj/board/Board.java
+++ b/src/main/java/fr/umlv/java/wallj/board/Board.java
@@ -5,6 +5,8 @@ import fr.umlv.java.wallj.utils.Matrix;
5 5
6/** 6/**
7 * An immutable BlockType matrix. 7 * An immutable BlockType matrix.
8 *
9 * @author Pacien TRAN-GIRARD
8 */ 10 */
9public final class Board { 11public final class Board {
10 12
diff --git a/src/main/java/fr/umlv/java/wallj/board/BoardParser.java b/src/main/java/fr/umlv/java/wallj/board/BoardParser.java
index b7db602..3d8386a 100644
--- a/src/main/java/fr/umlv/java/wallj/board/BoardParser.java
+++ b/src/main/java/fr/umlv/java/wallj/board/BoardParser.java
@@ -10,6 +10,11 @@ import java.util.List;
10import java.util.ListIterator; 10import java.util.ListIterator;
11import java.util.stream.Collectors; 11import java.util.stream.Collectors;
12 12
13/**
14 * Board deserializer.
15 *
16 * @author Pacien TRAN-GIRARD
17 */
13public final class BoardParser { 18public final class BoardParser {
14 19
15 private static Board buildBoard(List<List<BlockType>> map) { 20 private static Board buildBoard(List<List<BlockType>> map) {
@@ -28,7 +33,7 @@ public final class BoardParser {
28 case ' ': 33 case ' ':
29 return BlockType.FREE; 34 return BlockType.FREE;
30 case 'W': 35 case 'W':
31 return BlockType.wALL; 36 return BlockType.WALL;
32 case 'T': 37 case 'T':
33 return BlockType.TRASH; 38 return BlockType.TRASH;
34 case 'G': 39 case 'G':
@@ -44,6 +49,13 @@ public final class BoardParser {
44 .collect(Collectors.toList()); 49 .collect(Collectors.toList());
45 } 50 }
46 51
52 /**
53 * Parses a block from a file.
54 *
55 * @param filePath path to the map file
56 * @return the parsed Board
57 * @throws IOException any IO exception that happened while reading the file
58 */
47 public static Board parse(Path filePath) throws IOException { 59 public static Board parse(Path filePath) throws IOException {
48 return buildBoard(Files.lines(filePath) 60 return buildBoard(Files.lines(filePath)
49 .filter(s -> !s.isEmpty()) 61 .filter(s -> !s.isEmpty())
diff --git a/src/main/java/fr/umlv/java/wallj/board/TileVec2.java b/src/main/java/fr/umlv/java/wallj/board/TileVec2.java
index ac28b6d..6ccd116 100644
--- a/src/main/java/fr/umlv/java/wallj/board/TileVec2.java
+++ b/src/main/java/fr/umlv/java/wallj/board/TileVec2.java
@@ -6,6 +6,8 @@ import java.util.Objects;
6 6
7/** 7/**
8 * A typed immutable tile coordinate vector containing the coordinates of a Tile in a Board. 8 * A typed immutable tile coordinate vector containing the coordinates of a Tile in a Board.
9 *
10 * @author Pacien TRAN-GIRARD
9 */ 11 */
10public final class TileVec2 { 12public final class TileVec2 {
11 13
diff --git a/src/main/java/fr/umlv/java/wallj/utils/Matrix.java b/src/main/java/fr/umlv/java/wallj/utils/Matrix.java
index e3702bf..83dfc11 100644
--- a/src/main/java/fr/umlv/java/wallj/utils/Matrix.java
+++ b/src/main/java/fr/umlv/java/wallj/utils/Matrix.java
@@ -4,6 +4,8 @@ import java.util.List;
4 4
5/** 5/**
6 * Utility functions for two dimension arrays and lists. 6 * Utility functions for two dimension arrays and lists.
7 *
8 * @author Pacien TRAN-GIRARD
7 */ 9 */
8public final class Matrix { 10public final class Matrix {
9 11
diff --git a/src/test/java/fr/umlv/java/wallj/board/BoardParserTest.java b/src/test/java/fr/umlv/java/wallj/board/BoardParserTest.java
index fdeebbe..de6799b 100644
--- a/src/test/java/fr/umlv/java/wallj/board/BoardParserTest.java
+++ b/src/test/java/fr/umlv/java/wallj/board/BoardParserTest.java
@@ -9,6 +9,9 @@ import java.net.URISyntaxException;
9import java.nio.file.Path; 9import java.nio.file.Path;
10import java.nio.file.Paths; 10import java.nio.file.Paths;
11 11
12/**
13 * @author Pacien TRAN-GIRARD
14 */
12final class BoardParserTest { 15final class BoardParserTest {
13 16
14 private Path getResourcePath(String str) throws URISyntaxException { 17 private Path getResourcePath(String str) throws URISyntaxException {
@@ -24,7 +27,7 @@ final class BoardParserTest {
24 27
25 @Test 28 @Test
26 void testParse() throws IOException, URISyntaxException { 29 void testParse() throws IOException, URISyntaxException {
27 BlockType W = BlockType.wALL, F = BlockType.FREE, G = BlockType.GARBAGE, T = BlockType.TRASH; 30 BlockType W = BlockType.WALL, F = BlockType.FREE, G = BlockType.GARBAGE, T = BlockType.TRASH;
28 BlockType[][] blocks = new BlockType[][]{ 31 BlockType[][] blocks = new BlockType[][]{
29 {W, W, W, W, W, W}, 32 {W, W, W, W, W, W},
30 {W, F, G, F, T, W}, 33 {W, F, G, F, T, W},