-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameInfoPanel.java
More file actions
79 lines (69 loc) · 2.58 KB
/
GameInfoPanel.java
File metadata and controls
79 lines (69 loc) · 2.58 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
/**
* Lead Author:
* Ian Kligman; 5550139764
*
* References:
* Gaddis, T. (2015). Starting Out With Java Myprogramming Lab
* From Control Structures Through Objects. (6th ed.). Addison-Wesley.
*
*
* Version: 12/7/2022
*/
/**
* |-----------------------------------------------------------|
* | GameInfoPanel |
* |-----------------------------------------------------------|
* | Responsibilities | Collaborating Classes |
* |-------------------------------+---------------------------|
* | Create and display the | TreasureButton |
* | game info panel on the left | EmptyButton |
* | | TreasureButtonListener |
* | | EmptyButtonListener |
* | | LastMovePanel |
* | | GameFieldPanel |
* | | GameInfoPanel |
* |-------------------------------+---------------------------|
*/
// Required library imports for GUI and event listeners.
import javax.swing.*;
import java.awt.*;
public class GameInfoPanel extends JPanel
{
private JLabel remainingLabel;
private JLabel foundLabel;
private JLabel triesLabel;
private JLabel pointsLabel;
// Purpose: Constructor gives starting labels and sets the layout for the panel.
public GameInfoPanel()
{
setLayout(new GridLayout(4,1));
remainingLabel = new JLabel("Treasures left: " + 10);
foundLabel = new JLabel("Treasures found: " + 0);
triesLabel = new JLabel("Tries left: " + 20);
pointsLabel = new JLabel("Points: " + 0);
add(remainingLabel);
add(foundLabel);
add(triesLabel);
add(pointsLabel);
}
// Purpose: Update the tries label with inputed info.
public void setTries(String inputString, int counter)
{
triesLabel.setText(inputString + counter);
}
// Purpose: Update the remaining label with inputed info.
public void setRemaining(String inputString, int counter)
{
remainingLabel.setText(inputString + counter);
}
// Purpose: Update the found label with inputed info.
public void setFound(String inputString, int counter)
{
foundLabel.setText(inputString + counter);
}
// Purpose: Update the points label with inputed info.
public void setPoints(String inputString, int counter)
{
pointsLabel.setText(inputString + counter);
}
}