Advertisement
Guest User

position

a guest
Jan 29th, 2020
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. import java.util.Objects;
  2.  
  3. public class Position {
  4.  
  5. private int positionRow;
  6. private int positionColumn;
  7.  
  8. public Position(int row, int col) {
  9. super();
  10. this.positionRow = row;
  11. this.positionColumn = col;
  12. }
  13.  
  14. public int getRow() {
  15. return positionRow;
  16. }
  17. public void setRow(int newRow) {
  18. this.positionRow = newRow;
  19. }
  20. public int getCol() {
  21. return positionColumn;
  22. }
  23. public void setCol(int newCol) {
  24. this.positionColumn = newCol;
  25. }
  26.  
  27.  
  28. public boolean equals(Position otherPosition) {
  29.  
  30. if (otherPosition == null)
  31. return false;
  32. if (getClass() != otherPosition.getClass())
  33. return false;
  34. Position other = (Position) otherPosition; //assigning "other" to another instance
  35. return positionColumn == other.positionColumn && positionRow == other.positionRow;
  36. }
  37.  
  38.  
  39.  
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement