Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Position {
- private int positionRow;
- private int positionColumn;
- public Position(int row, int column) {
- positionColumn = column;
- positionRow = row;
- }
- public int getRow() {
- return positionRow;
- }
- public int getCol() {
- return positionColumn;
- }
- public void setRow (int newRow) {
- positionRow = newRow;
- }
- public void setCol (int newCol) {
- positionColumn = newCol;
- }
- public boolean equals (Position otherPosition) {
- if (otherPosition.getRow() == this.getRow() && otherPosition.getCol() == this.getCol() ) {
- return true;
- } else {
- return false;
- }
- }
- public static void main (String[] args) {
- Position pos1 = new Position(1,2);
- Position pos2 = new Position(1,2);
- System.out.println(pos1.equals(pos2));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement