-
Notifications
You must be signed in to change notification settings - Fork 0
/
Location.java
52 lines (41 loc) · 890 Bytes
/
Location.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
public class Location {
private int row, col;
public Location(int r, int c){
row = r;
col = c;
}
public boolean equals(Location loc){
return (row == loc.getRow() && col == loc.getCol());
}
public void setLocation(int r,int c){
row = r;
col = c;
}
public void setLocation(Location l){
row = l.getRow();
col = l.getCol();
}
public int findDistance(int r,int c){
return 1;
}
public int getRow(){
return row;
}
public int getCol(){
return col;
}
public boolean collision(Location l) {
if ((row - l.getRow() < 30) && (row -l.getRow() > -30)) {
if ((col - l.getCol() < 30) && (col -l.getCol() > -30))
return true;
}
return false;
}
public boolean m_collision(Location l) {
if ((row - l.getRow() < 50) && (row -l.getRow() > -50)) {
if ((col - l.getCol() < 50) && (col -l.getCol() > -50))
return true;
}
return false;
}
}