Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Objects;
- public class Position {
- private int positionRow;
- private int positionColumn;
- public Position(int row, int col) {
- super();
- this.positionRow = row;
- this.positionColumn = col;
- }
- public int getRow() {
- return positionRow;
- }
- public void setRow(int newRow) {
- this.positionRow = newRow;
- }
- public int getCol() {
- return positionColumn;
- }
- public void setCol(int newCol) {
- this.positionColumn = newCol;
- }
- public boolean equals(Position otherPosition) {
- if (otherPosition == null)
- return false;
- if (getClass() != otherPosition.getClass())
- return false;
- Position other = (Position) otherPosition; //assigning "other" to another instance
- return positionColumn == other.positionColumn && positionRow == other.positionRow;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement