-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTokens.java
More file actions
67 lines (55 loc) · 1.63 KB
/
Copy pathTokens.java
File metadata and controls
67 lines (55 loc) · 1.63 KB
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
61
62
63
64
65
66
67
import java.awt.Color;
import java.util.ArrayList;
import java.util.Iterator;
/**
* This creates all the tokens and allows the interface iterable to be used on the class
*
* @Team MAGA
* @Author Gajun Young - 16440714
* @Author Royal Thomas - 16326926
* @Author Richard Otroshchenko - 16353416
*/
public class Tokens implements Iterable<Token>, Iterator<Token> {
private static final int DEFAULT_CAPACITY = 6;
private final ArrayList<Token> tokens;
private Iterator<Token> iterator;
private TileGrid grid = new TileGrid();
public Tokens() {
tokens = new ArrayList<Token>(DEFAULT_CAPACITY);
createPlayers();
}
public Tokens(int capacity) {
tokens = new ArrayList<Token>(capacity);
}
//Iterates to get a specific Token
public Token get(String name) {
for (Token Token : tokens) {
if (Token.hasName(name)) {
return Token;
}
}
return null;
}
//Creating a list of players [Fixed starting location]
public void createPlayers() {
tokens.add(new Token("Plum", Color.magenta, grid.map[19][23]));
tokens.add(new Token("White", Color.white, grid.map[0][9]));
tokens.add(new Token("Scarlet", Color.red, grid.map[24][7]));
tokens.add(new Token("Green", Color.green, grid.map[0][14]));
tokens.add(new Token("Mustard", Color.yellow, grid.map[17][0]));
tokens.add(new Token("Peacock", Color.blue, grid.map[6][23]));
}
@Override
public Iterator<Token> iterator() {
iterator = tokens.iterator();
return iterator;
}
@Override
public boolean hasNext() {
return iterator.hasNext();
}
@Override
public Token next() {
return iterator.next();
}
}