Skip to content

Commit

Permalink
Added equality method to move to use in testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron committed Apr 29, 2016
1 parent 76fa25c commit cdf6293
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
7 changes: 7 additions & 0 deletions src/model/Move.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 + ")" +
Expand Down
10 changes: 2 additions & 8 deletions src/test/CommunicationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,8 @@ public CommunicationTest() {
}

public boolean moveExistsInSet(Move move, ArrayList<Move> 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;
}

Expand Down

0 comments on commit cdf6293

Please sign in to comment.