diff options
Diffstat (limited to 'src/main/java/fr/umlv/java/wallj/board/Board.java')
-rw-r--r-- | src/main/java/fr/umlv/java/wallj/board/Board.java | 64 |
1 files changed, 32 insertions, 32 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 2e67c53..077dd26 100644 --- a/src/main/java/fr/umlv/java/wallj/board/Board.java +++ b/src/main/java/fr/umlv/java/wallj/board/Board.java | |||
@@ -15,38 +15,6 @@ import java.util.stream.Stream; | |||
15 | */ | 15 | */ |
16 | public final class Board { | 16 | public final class Board { |
17 | 17 | ||
18 | /** | ||
19 | * Board Builder | ||
20 | */ | ||
21 | public static final class Builder { | ||
22 | private final BlockType[][] map; | ||
23 | |||
24 | /** | ||
25 | * @param width width in tiles | ||
26 | * @param height height in tiles | ||
27 | */ | ||
28 | public Builder(int width, int height) { | ||
29 | map = new BlockType[height][width]; | ||
30 | } | ||
31 | |||
32 | /** | ||
33 | * @param pos the tile position vector | ||
34 | * @param type the BlockType to set | ||
35 | * @return the Builder | ||
36 | */ | ||
37 | public Builder setBlockTypeAt(TileVec2 pos, BlockType type) { | ||
38 | map[pos.getRow()][pos.getCol()] = type; | ||
39 | return this; | ||
40 | } | ||
41 | |||
42 | /** | ||
43 | * @return the immutable Board | ||
44 | */ | ||
45 | public Board build() { | ||
46 | return new Board(map); | ||
47 | } | ||
48 | } | ||
49 | |||
50 | private final BlockType[][] map; | 18 | private final BlockType[][] map; |
51 | 19 | ||
52 | private Board(BlockType[][] map) { | 20 | private Board(BlockType[][] map) { |
@@ -103,4 +71,36 @@ public final class Board { | |||
103 | return Arrays.hashCode(map); | 71 | return Arrays.hashCode(map); |
104 | } | 72 | } |
105 | 73 | ||
74 | /** | ||
75 | * Board Builder | ||
76 | */ | ||
77 | public static final class Builder { | ||
78 | private final BlockType[][] map; | ||
79 | |||
80 | /** | ||
81 | * @param width width in tiles | ||
82 | * @param height height in tiles | ||
83 | */ | ||
84 | public Builder(int width, int height) { | ||
85 | map = new BlockType[height][width]; | ||
86 | } | ||
87 | |||
88 | /** | ||
89 | * @param pos the tile position vector | ||
90 | * @param type the BlockType to set | ||
91 | * @return the Builder | ||
92 | */ | ||
93 | public Builder setBlockTypeAt(TileVec2 pos, BlockType type) { | ||
94 | map[pos.getRow()][pos.getCol()] = type; | ||
95 | return this; | ||
96 | } | ||
97 | |||
98 | /** | ||
99 | * @return the immutable Board | ||
100 | */ | ||
101 | public Board build() { | ||
102 | return new Board(map); | ||
103 | } | ||
104 | } | ||
105 | |||
106 | } | 106 | } |