-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPosition.java
More file actions
42 lines (33 loc) · 861 Bytes
/
Position.java
File metadata and controls
42 lines (33 loc) · 861 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
public class Position {
private int col;
private int row;
public Position(int col, int row){
this.col = col;
this.row = row;
}
public Position(Position position){
this.col = position.col;
this.row = position.row;
}
public int getCol(){
return this.col;
}
public void setCol(int col){
this.col = col;
}
public void setRow(int row){
this.row = row;
}
public int getRow(){
return this.row;
}
public boolean notDiagonal(Position b) {
return col == b.getCol() || row == b.getRow();
}
public boolean equals(Position p){
return getRow() == p.getRow() && getCol() == p.getCol();
}
public String toString(){
return "("+getCol()+", "+getRow()+")";
}
}