diff options
Diffstat (limited to 'src')
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 | */ |
9 | public final class Board { | 11 | public 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; | |||
10 | import java.util.ListIterator; | 10 | import java.util.ListIterator; |
11 | import java.util.stream.Collectors; | 11 | import java.util.stream.Collectors; |
12 | 12 | ||
13 | /** | ||
14 | * Board deserializer. | ||
15 | * | ||
16 | * @author Pacien TRAN-GIRARD | ||
17 | */ | ||
13 | public final class BoardParser { | 18 | public 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 | */ |
10 | public final class TileVec2 { | 12 | public 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 | */ |
8 | public final class Matrix { | 10 | public 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; | |||
9 | import java.nio.file.Path; | 9 | import java.nio.file.Path; |
10 | import java.nio.file.Paths; | 10 | import java.nio.file.Paths; |
11 | 11 | ||
12 | /** | ||
13 | * @author Pacien TRAN-GIRARD | ||
14 | */ | ||
12 | final class BoardParserTest { | 15 | final 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}, |