aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorpacien2018-01-11 21:45:05 +0100
committerpacien2018-01-11 21:45:05 +0100
commit6760ddb7a47b96dae5b1b626417dcf3cbd4055b1 (patch)
tree0e919dc3c36d186e544221055cb9284aed93d8bc /src/main/java
parent7fc6fc06bf5b1e6c3a07640cfb2ac7456e030e06 (diff)
downloadwallj-6760ddb7a47b96dae5b1b626417dcf3cbd4055b1.tar.gz
Implement board equals and hashCode
Signed-off-by: pacien <pacien.trangirard@pacien.net>
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/fr/umlv/java/wallj/board/Board.java15
1 files changed, 15 insertions, 0 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 c846fd3..015a4c0 100644
--- a/src/main/java/fr/umlv/java/wallj/board/Board.java
+++ b/src/main/java/fr/umlv/java/wallj/board/Board.java
@@ -3,6 +3,8 @@ package fr.umlv.java.wallj.board;
3import fr.umlv.java.wallj.model.BlockType; 3import fr.umlv.java.wallj.model.BlockType;
4import fr.umlv.java.wallj.utils.Matrix; 4import fr.umlv.java.wallj.utils.Matrix;
5 5
6import java.util.Arrays;
7
6/** 8/**
7 * An immutable BlockType matrix. 9 * An immutable BlockType matrix.
8 * 10 *
@@ -65,4 +67,17 @@ public final class Board {
65 return TileVec2.of(Matrix.getWidth(map), Matrix.getHeight(map)); 67 return TileVec2.of(Matrix.getWidth(map), Matrix.getHeight(map));
66 } 68 }
67 69
70 @Override
71 public boolean equals(Object o) {
72 if (this == o) return true;
73 if (!(o instanceof Board)) return false;
74 Board board = (Board) o;
75 return Arrays.deepEquals(map, board.map);
76 }
77
78 @Override
79 public int hashCode() {
80 return Arrays.hashCode(map);
81 }
82
68} 83}