diff options
author | Timothée Floure | 2016-03-01 16:26:40 +0100 |
---|---|---|
committer | Timothée Floure | 2016-03-01 16:26:40 +0100 |
commit | b25cee830238c64c08a2e3733bbed0730d20a734 (patch) | |
tree | 5f4d0a6d8c69f0373db313a442d0e969d3228e07 | |
parent | 55e19228a2b9119f136f62b050421ac91cdecf53 (diff) | |
download | xblast-b25cee830238c64c08a2e3733bbed0730d20a734.tar.gz |
Add the blocksAt() and blockAt() methods to the Board class
-rw-r--r-- | src/ch/epfl/xblast/server/Board.java | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/ch/epfl/xblast/server/Board.java b/src/ch/epfl/xblast/server/Board.java index 5e899f6..2cbf380 100644 --- a/src/ch/epfl/xblast/server/Board.java +++ b/src/ch/epfl/xblast/server/Board.java | |||
@@ -2,6 +2,7 @@ package ch.epfl.xblast.server; | |||
2 | 2 | ||
3 | import ch.epfl.cs108.Sq; | 3 | import ch.epfl.cs108.Sq; |
4 | import ch.epfl.xblast.Lists; | 4 | import ch.epfl.xblast.Lists; |
5 | import ch.epfl.xblast.Cell; | ||
5 | 6 | ||
6 | import java.util.ArrayList; | 7 | import java.util.ArrayList; |
7 | import java.util.List; | 8 | import java.util.List; |
@@ -123,4 +124,23 @@ public final class Board { | |||
123 | return ofInnerBlocksWalled(rowsList); | 124 | return ofInnerBlocksWalled(rowsList); |
124 | } | 125 | } |
125 | 126 | ||
127 | /** | ||
128 | * Return the sequence of blocks related to the given cell. | ||
129 | * | ||
130 | * @param c cell | ||
131 | * @return the sequence of blocks related to the given cell. | ||
132 | */ | ||
133 | public Sq<Block> blocksAt(Cell c) { | ||
134 | return blocks.get(c.rowMajorIndex()); | ||
135 | } | ||
136 | |||
137 | /** | ||
138 | * Returns the block related to the given cell. | ||
139 | * | ||
140 | * @param c cell | ||
141 | * @return the first block of the sequence related to the given cell | ||
142 | */ | ||
143 | public Block blockAt(Cell c) { | ||
144 | return blocksAt(c).head(); | ||
145 | } | ||
126 | } | 146 | } |