diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ch/epfl/xblast/Cell.java | 2 | ||||
-rw-r--r-- | src/ch/epfl/xblast/SubCell.java | 11 |
2 files changed, 11 insertions, 2 deletions
diff --git a/src/ch/epfl/xblast/Cell.java b/src/ch/epfl/xblast/Cell.java index 098c19c..a8a5a08 100644 --- a/src/ch/epfl/xblast/Cell.java +++ b/src/ch/epfl/xblast/Cell.java | |||
@@ -181,7 +181,7 @@ public final class Cell { | |||
181 | */ | 181 | */ |
182 | @Override | 182 | @Override |
183 | public int hashCode() { | 183 | public int hashCode() { |
184 | return 0; // TODO | 184 | return this.rowMajorIndex(); |
185 | } | 185 | } |
186 | 186 | ||
187 | /** | 187 | /** |
diff --git a/src/ch/epfl/xblast/SubCell.java b/src/ch/epfl/xblast/SubCell.java index 3b7fdb1..8a25997 100644 --- a/src/ch/epfl/xblast/SubCell.java +++ b/src/ch/epfl/xblast/SubCell.java | |||
@@ -143,7 +143,7 @@ public final class SubCell { | |||
143 | */ | 143 | */ |
144 | @Override | 144 | @Override |
145 | public int hashCode() { | 145 | public int hashCode() { |
146 | return 0; // TODO | 146 | return this.rowMajorIndex(); |
147 | } | 147 | } |
148 | 148 | ||
149 | /** | 149 | /** |
@@ -156,4 +156,13 @@ public final class SubCell { | |||
156 | return String.format("(%d,%d)", this.x, this.y); | 156 | return String.format("(%d,%d)", this.x, this.y); |
157 | } | 157 | } |
158 | 158 | ||
159 | /** | ||
160 | * Returns the index of the SubCell (major ordered). | ||
161 | * | ||
162 | * @return the index of the SubCell | ||
163 | */ | ||
164 | private int rowMajorIndex() { | ||
165 | return this.y * SUB_COLUMNS + this.x; | ||
166 | } | ||
167 | |||
159 | } | 168 | } |