diff --git a/src/model/Move.java b/src/model/Move.java index 5e288bf..4c3852a 100644 --- a/src/model/Move.java +++ b/src/model/Move.java @@ -14,6 +14,13 @@ public boolean isJump() { && Math.abs(source.row - destination.row) == 2; } + public boolean equals(Move other) { + return this.destination.row == other.destination.row && + this.destination.column == other.destination.column && + this.source.row == other.source.row && + this.source.column == other.source.column; + } + @Override public String toString() { return "From (" + this.source.row + ", " + this.source.column + ")" + diff --git a/src/test/CommunicationTest.java b/src/test/CommunicationTest.java index 87278dc..2f617d3 100755 --- a/src/test/CommunicationTest.java +++ b/src/test/CommunicationTest.java @@ -13,14 +13,8 @@ public CommunicationTest() { } public boolean moveExistsInSet(Move move, ArrayList set) { - for (Move m : set) { - if ( move.destination.row == m.destination.row && - move.destination.column == m.destination.column && - move.source.row == m.source.row && - move.source.column == m.source.column) { - return true; - } - } + for (Move m : set) + if (move.equals(m)) return true; return false; }