/
CommandMenuController.java
60 lines (36 loc) · 1.15 KB
/
CommandMenuController.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import java.awt.event.ActionEvent;
import javax.swing.JOptionPane;
public class CommandMenuController extends MazeController {
private Maze maze;
public CommandMenuController(MazeGUI gui) {
super(gui);
}
public void actionPerformed(ActionEvent e) {
//Get the new maze (updated maze) every time you perform
//an action.
maze = get_TheMaze();
String cmmd = e.getActionCommand();
if (cmmd.equals("North")) {
maze.move("North");
return;
}
if (cmmd.equals("South")) {
maze.move("South");
return;
}
if (cmmd.equalsIgnoreCase("West")) {
maze.move("West");
return;
}
if (cmmd.equalsIgnoreCase("East")) {
maze.move("East");
return;
}
if (cmmd.equalsIgnoreCase("Reset")) {
if (0 == JOptionPane.showConfirmDialog(null, "Do you want to reset the game?")) {
maze.move("Reset");
return;
}
}
}//ActionPerformed
}//class