aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPacien TRAN-GIRARD2016-03-15 15:36:32 +0100
committerPacien TRAN-GIRARD2016-03-15 15:36:32 +0100
commit05dc6bb3d944a3edb90f62dfbe8b85b044839ee7 (patch)
tree137345a46b0a02f377dc2292c0a01c7a12e2ff3d /src
parent1db4b8177f0ab000291d584f5595c10af93636e6 (diff)
downloadxblast-05dc6bb3d944a3edb90f62dfbe8b85b044839ee7.tar.gz
Implement Cell and SubCell hashCode() methods
Diffstat (limited to 'src')
-rw-r--r--src/ch/epfl/xblast/Cell.java2
-rw-r--r--src/ch/epfl/xblast/SubCell.java11
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}