-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathToken.java
53 lines (46 loc) · 1.1 KB
/
Token.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
import java.util.Stack;
public class Token
{
// Instance Variables
private char tokenColor;
private int tokenNum;
private int tokenYCoord;
private int tokenXCoord;
//Constructor
public Token(Stack<Token> tokenStack)
{
this.tokenColor = (tokenStack.size() % 2 == 0) ? 'y' : 'r';
this.tokenNum = tokenStack.size() + 1;
}
// Getters
public char getColor()
{
return this.tokenColor;
}
public int getTokenNum()
{
return this.tokenNum;
}
public int getYCoord()
{
return this.tokenYCoord;
}
public int getXCoord()
{
return this.tokenXCoord;
}
// Public methods
public boolean dropToken(int droppedColumn, char[][] boardGrid)
{
for(int y = boardGrid.length - 1; y > 0; y--)
{
if(boardGrid[y][droppedColumn] == '*')
{
this.tokenYCoord = y;
this.tokenXCoord = droppedColumn;
return true;
}
}
return false;
}
}