-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
25 lines (19 loc) · 890 Bytes
/
Main.java
File metadata and controls
25 lines (19 loc) · 890 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
// Press Shift twice to open the Search Everywhere dialog and type `show whitespaces`,
// then press Enter. You can now see whitespace characters in your code.
public class Main {
public static void main(String[] args)
{
//client is the invoker
//invoker knows which command to invoke
//executor knows how to execute the command
//controller will take the command from the invoker to the executor
TV tv = new TV(); //executor
Remote remote = new Remote(); //controller
Command tvOnCommand = new TvOnCommand(tv); //tv on cmd
Command tvOffCommand = new TvOffCommand(tv); // tv off cmd
remote.setCommand(tvOnCommand);
remote.pressButton(); //invoking the tv on command
remote.setCommand(tvOffCommand);
remote.pressButton(); //invoking the tv off command
}
}