-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathFallBall.java
50 lines (41 loc) · 1.04 KB
/
FallBall.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
//using this one for the final
public class FallBall{
private int whereRow, whereCol;
public FallBall(int whereR, int whereC){
whereRow = whereR;
whereCol = whereC;
}
public boolean isFrontOpen(int[][] board){
if(whereRow == board.length - 1)
return false;
else if(board[whereRow + 1][whereCol] == 1)
return false;
else return true;
}
public boolean isRightOpen(int [][] board){
if(whereCol == board[0].length - 1)
return false;
else if(board[whereRow][whereCol + 1] == 1)
return false;
else return true;
}
public boolean isLeftOpen(int [][] board){
if(whereCol == 0)
return false;
else if(board[whereRow][whereCol - 1] == 1)
return false;
else return true;
}
public int getRow(){
return whereRow;
}
public int getCol(){
return whereCol;
}
public void setRow(int r){
whereRow = r;
}
public void setCol(int c){
whereCol = c;
}
}