-
Notifications
You must be signed in to change notification settings - Fork 0
/
UnfilledCounter.java
36 lines (29 loc) · 1.08 KB
/
UnfilledCounter.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
package sudoku;
import javax.swing.*;
import java.awt.*;
public class UnfilledCounter extends JPanel{
private static final long serialVersionUID = 1L; // to prevent serial warning
private JLabel label;
private int count;
public UnfilledCounter() {
label = new JLabel(String.format("Unfilled Count: %d", count));
add(label);
label.setFont(new Font("Verdana", Font.BOLD, 22));
label.setForeground(Color.WHITE);
}
public void increment() {
count = 0;
for(int i = 0;i<GameBoardPanel.GRID_SIZE;i++){
for(int j =0;j<GameBoardPanel.GRID_SIZE;j++){
if(GameBoardPanel.cells[i][j].status == CellStatus.TO_GUESS){
count++;
}
}
}
/*if(count != chances_max) { //不要讓人家發現可以顯示錯誤次數高於上限
count++;
}*/
//label.setText(String.format("Mistake Count: %d/%d", count, chances_max));
label.setText(String.format("Unfilled Count: %d", count));
}
}