-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCenter.java
More file actions
68 lines (55 loc) · 1.55 KB
/
Center.java
File metadata and controls
68 lines (55 loc) · 1.55 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
68
import java.util.*;
public class Center {
private ArrayList<Tile> centerTiles;
private boolean firstToken;
private int x, y;
//Contructor
public Center(int x, int y, ArrayList<Tile> centerTiles) {
resetFirstToken();
this.centerTiles = centerTiles;
this.x = x;
this.y = y;
}
//Returns an arraylist of a color and removes them from the centerTiles
public void drawCenterColor(String color) {
for(int i = 0; i<centerTiles.size(); i++) {
centerTiles.get(i).deselect();
if(centerTiles.get(i).getColor().equals(color)) {
centerTiles.remove(i);
i--;
}
}
}
public ArrayList<Tile> selectOfColor(String color){
ArrayList<Tile> tilesOfColor = new ArrayList<>();
for(Tile t:centerTiles) {
if(t.getColor().equals(color)) {
tilesOfColor.add(t);
}
}
return tilesOfColor;
}
//Adds an arraylist of tiles to the centerTiles
public void addCenterTiles(ArrayList<Tile> newTiles) {
for(Tile tile:newTiles) {
centerTiles.add(tile);
}
}
//Returns if there is a first token
public boolean hasFirstToken() {return firstToken;}
//Resets the first token back to true
public void resetFirstToken() {firstToken = true;}
//draws the first token and sets first token to false
public void takeFirstToken() {
firstToken = false;
}
//returns the tiles in the center
public ArrayList<Tile> getCenterTiles(){return centerTiles;}
public int getX() {return x;}
public int getY() {return y;}
public boolean isEmpty() {return centerTiles.isEmpty();}
public void setCoords(int x, int y) {
this.x = x;
this.y = y;
}
}