From 6760ddb7a47b96dae5b1b626417dcf3cbd4055b1 Mon Sep 17 00:00:00 2001 From: pacien Date: Thu, 11 Jan 2018 21:45:05 +0100 Subject: Implement board equals and hashCode Signed-off-by: pacien --- src/main/java/fr/umlv/java/wallj/board/Board.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/main/java/fr/umlv') 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; import fr.umlv.java.wallj.model.BlockType; import fr.umlv.java.wallj.utils.Matrix; +import java.util.Arrays; + /** * An immutable BlockType matrix. * @@ -65,4 +67,17 @@ public final class Board { return TileVec2.of(Matrix.getWidth(map), Matrix.getHeight(map)); } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof Board)) return false; + Board board = (Board) o; + return Arrays.deepEquals(map, board.map); + } + + @Override + public int hashCode() { + return Arrays.hashCode(map); + } + } -- cgit v1.2.3