forked from rick2785/JavaCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeviceButton.java
More file actions
33 lines (19 loc) · 551 Bytes
/
DeviceButton.java
File metadata and controls
33 lines (19 loc) · 551 Bytes
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
// This is known as the invoker
// It has a method press() that when executed
// causes the execute method to be called
// The execute method for the Command interface then calls
// the method assigned in the class that implements the
// Command interface
public class DeviceButton{
Command theCommand;
public DeviceButton(Command newCommand){
theCommand = newCommand;
}
public void press(){
theCommand.execute();
}
// Now the remote can undo past commands
public void pressUndo(){
theCommand.undo();
}
}