-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPosition.java
60 lines (44 loc) · 1.28 KB
/
Position.java
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
* This class assist in handling with the positions of diffrent objects.
*/
package bomborman;
import bomborman.Types.Move;
public class Position {
private int row, col;
public Position(int _row, int _col){
row = _row;
col = _col;
}
public boolean equals(Position position){
if( position.getColumn() == col && position.getRow() == row){
return true;
}else{
return false;
}
}
public int getColumn(){ return col;}
public int getRow(){ return row;}
public void setPosition(Position position){
row = position.getRow();
col = position.getColumn();
}
public void setPosition(int _row, int _col){
row = _row;
col = _col;
}
public Position increment(Move m){
Position temp;
if(m == Move.UP){
temp = new Position(row-1,col);
}else if(m==Move.DOWN){
temp = new Position(row+1,col);
}else if(m==Move.RIGHT){
temp = new Position(row,col+1);
}else if(m==Move.LEFT){
temp = new Position(row,col-1);
}else{
temp = new Position(row,col);
}
return temp;
}
}