-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameButton.java
More file actions
77 lines (59 loc) · 1.54 KB
/
Copy pathGameButton.java
File metadata and controls
77 lines (59 loc) · 1.54 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
69
70
71
72
73
74
75
76
77
import javax.swing.*;
public class GameButton extends JButton {
private int x, y;
private boolean isBomb;
private int bombsAround;
private boolean isChecked = false;
private boolean isFlagged = false;
public static int amtTiles;
public static int amtBomb;
public static int amtChecked;
public GameButton(String text, int x, int y, boolean isBomb) {
super.setText(text);
this.x = x;
this.y = y;
amtTiles++;
}
public void setBomb(boolean isBomb){
// only changes the amtBomb if the current state is not isBomb
if(isBomb != this.isBomb()){
this.isBomb = isBomb;
if(isBomb){
amtBomb++;
} else{
amtBomb--;
}
}
}
public int getbX(){
return this.x;
}
public int getbY(){
return this.y;
}
public boolean isBomb(){
return this.isBomb;
}
public int getBombsAround() {
return bombsAround;
}
public void setBombsAround(int bombsAround) {
this.bombsAround = bombsAround;
}
public boolean isChecked() {
return isChecked;
}
public void setChecked(boolean checked) {
// tiles that are bombs does not count as checked
if(!this.isBomb && !this.isChecked){
amtChecked++;
}
this.isChecked = checked;
}
public boolean isFlagged() {
return isFlagged;
}
public void setFlagged(boolean flagged) {
isFlagged = flagged;
}
}