-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCell.java
More file actions
102 lines (85 loc) · 2.36 KB
/
Copy pathCell.java
File metadata and controls
102 lines (85 loc) · 2.36 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
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
import java.awt.Graphics;
import java.awt.Image;
import javax.swing.ImageIcon;
public class Cell {
private int row;
private int column;
private int numOfAdjacentMines;
private boolean isMine;
private String status = "cvrd";
public Cell(int row, int column, int numOfAdjacentMines, boolean isMine) {
this.row = row;
this.column = column;
this.numOfAdjacentMines = numOfAdjacentMines;
this.isMine = isMine;
}
public int getRow() {
return this.row;
}
public int getCol() {
return this.column;
}
public void setMines(int mineCount) {
this.numOfAdjacentMines = mineCount;
}
public int getNumOfAdjacentMines() {
return this.numOfAdjacentMines;
}
public boolean isMine() {
return this.isMine;
}
public void draw(Graphics g) {
g.drawImage(this.getImage(), this.getHorizontalPosition(), this.getVerticalPosition(), null);
}
public String getStatus() {
return this.status;
}
public void setStatus(String status) {
this.status = status;
}
public Image getImage() {
Image image;
if(this.isMine) {
if(this.status.equals("mrkd")) {
ImageIcon a = new ImageIcon("img/marked_cell.png");
image = a.getImage();
}
else if(this.status.equals("opnd")) {
ImageIcon a = new ImageIcon("img/mine_cell.png");
image = a.getImage();
}
else /*(status.equals(Configuration.STATUS_COVERED))*/ {
ImageIcon a = new ImageIcon("img/covered_cell.png");
image = a.getImage();
}
return image;
}
else {
if (status.equals("cvrd")) {
ImageIcon a = new ImageIcon("img/covered_cell.png");
image = a.getImage();
}
else if(status.equals("mrkd")) {
ImageIcon a = new ImageIcon("img/marked_cell.png");
image = a.getImage();
}
else if(status.equals("wmrkd")){
ImageIcon a = new ImageIcon("img/wrong_mark.png");
image = a.getImage();
}
else /*(status.equals(Configuration.STATUS_OPENED))*/ {
ImageIcon a = new ImageIcon("img/info_" + this.numOfAdjacentMines + ".png");
image = a.getImage();
}
return image;
}
}
private int getHorizontalPosition() {
return (column) * Configuration.CELL_SIZE;
//Calculates and returns the pixel-level horizontal position of the top-left corner of the cell
}
private int getVerticalPosition() {
return (row) * Configuration.CELL_SIZE;
//Calculates and returns the pixel-level vertical position of the top-left corner of the cell
}
}