-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFactoryFloor.java
121 lines (115 loc) · 2.34 KB
/
FactoryFloor.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import java.awt.Color;
import java.awt.Point;
import java.util.ArrayList;
import javax.swing.BorderFactory;
public class FactoryFloor {
ArrayList <PlainButton> ButtonList;
int [] colors;
Boolean firstMarker, firsttaken;
//~
// NORMAL METHODS
//~
FactoryFloor (){
ButtonList = new ArrayList <PlainButton>();
colors = new int [5];
firstMarker = true;
firsttaken = false;
setCoordinates();
}
/**
* addes this arraylist of tiles to the big array
* @param tiles
*/
public void add(ArrayList <Integer> tiles) {
for (int i = 0; i < 5; i++) {
while (tiles.contains(i)) {
colors [i] += 1;
tiles.remove(tiles.indexOf(i));
}
}
}
public void add(int color) {
colors [color] += 1;
}
public int takeAll(int color) {
int num = colors[color];
colors[color] = 0;
return num;
}
/**
* sets the coordinates of the factoryFloor buttons
* @param i
* @return
*/
//TODO
public void setCoordinates () {
for (int i = 0; i < ButtonList.size(); i++) {
int x = 0;
int y = 0;
switch(i) {
case 0:{
x = 715;
y = 86;
break;
}
case 1:{
x = 0;
y = 0;
break;
}
case 2:{
x = 0;
y = 0;
break;
}
case 3:{
x = 0;
y = 0;
break;
}
case 4:{
x = 0;
y = 0;
break;
}
}
ButtonList.get(i).setLocation(x,y);
}
}
//~
//----------BUTTON SECTION
//~
/**
*
* @param bool
*/
public void setEnabled (Boolean bool) {
for (int i = 0; i < colors.length; i++) {
if (colors[i]<=0)
ButtonList.get(i).setEnabled(false);
else
ButtonList.get(i).setEnabled(bool);
}
}
//TODO
//need the algorithm for each button coordinate
public void addButtons(ArrayList <PlainButton> buttons) {
for (int r = 0; r < buttons.size(); r ++) {
PlainButton temp = buttons.get(r);
if (r == 0)
temp.setLocation(715-10, 86-10);
if (r ==1)
temp.setLocation(907-10, 91-10);
if (r ==2)
temp.setLocation(1110-10, 91-10);
if (r ==3)
temp.setLocation(715-10, 199-10);
if (r ==4)
temp.setLocation(907-10, 199-10);
if (r ==5)
temp.setLocation(1110-10, 199-10);
//temp.setBorder(BorderFactory.createBevelBorder(10));
ButtonList.add(temp);
}
}
}