-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLastMovePanel.java
More file actions
72 lines (62 loc) · 2.25 KB
/
LastMovePanel.java
File metadata and controls
72 lines (62 loc) · 2.25 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
/**
* 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
*/
/**
* |-----------------------------------------------------------|
* | LastMovePanel |
* |-----------------------------------------------------------|
* | Responsibilities | Collaborating Classes |
* |-------------------------------+---------------------------|
* | Display last move info. | TreasureButtonListener |
* | | TreasureGameView |
* | | EmptyButtonListener |
* | | GameFieldPanel |
* | | GameInfoPanel |
* |-------------------------------+---------------------------|
*/
// Required library imports for GUI and event listeners.
import javax.swing.*;
import java.awt.*;
public class LastMovePanel extends JPanel
{
private JLabel lastMoveLabel;
// Purpose: Create the starting contidion for the last move label and add it to the panel.
public LastMovePanel()
{
lastMoveLabel = new JLabel("GOOD LUCK!");
add(lastMoveLabel);
}
// Purpose: Will be activated by action listeners if an empty button is clicked.
public void fail()
{
lastMoveLabel.setText("Last Move: found nothing...");
}
// Purpose: Will be activated by action listeners if a treasure button is clicked.
public void success(int points)
{
lastMoveLabel.setText("Last Move: found treasure! +" + points + " points");
}
// Purpose: Will be activated if the user encounters a troll.
public void troll()
{
lastMoveLabel.setText("Last Move: robbed by a troll :(");
}
// Purpose: Will be activated if the user runs out of tries.
public void gameOver()
{
lastMoveLabel.setText("Game Over - You lose");
}
// Purpose: Will be activated if the user finds all treasure before running out of tries.
public void youWin()
{
lastMoveLabel.setText("Game Over - You Win");
}
}