/
NavigationController.java
64 lines (35 loc) · 1.22 KB
/
NavigationController.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
61
62
63
64
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
public class NavigationController extends MazeController implements ActionListener {
private Maze maze;
public NavigationController(MazeGUI gui) {
super(gui);
}
public void actionPerformed(ActionEvent e) {
maze = get_TheMaze();
String button_push = e.getActionCommand();
if(button_push=="North") {
maze.move("North");
return;
}
if(button_push=="South") {
maze.move("South");
return;
}
if(button_push=="West"){
maze.move("West");
return;
}
if(button_push=="East"){
maze.move("East");
return;
}
if(button_push=="Reset"){
if(0 == JOptionPane.showConfirmDialog(null, "Do you want to reset the game?")) {
maze.move("Reset");
return;
}
}
}//end of ActionPerformed method
}//end of class