@@ -4,47 +4,47 @@ public class Client {
44
55 public static void main (String [] args ) {
66 // TODO Auto-generated method stub
7-
8- //ʹ���������ģʽ�����ͨ��ң�������Ե�ƵIJ���
9-
10- //������ƵĶ���(������ )
7+
8+ //使用命令设计模式,完成通过遥控器,对电灯的操作
9+
10+ //创建电灯的对象(接受者 )
1111 LightReceiver lightReceiver = new LightReceiver ();
12-
13- //���������صĿ�������
12+
13+ //创建电灯相关的开关命令
1414 LightOnCommand lightOnCommand = new LightOnCommand (lightReceiver );
1515 LightOffCommand lightOffCommand = new LightOffCommand (lightReceiver );
16-
17- //��Ҫһ��ң����
16+
17+ //需要一个遥控器
1818 RemoteController remoteController = new RemoteController ();
19-
20- //�����ǵ�ң������������, ���� no = 0 �ǵ�ƵĿ��صIJ���
19+
20+ //给我们的遥控器设置命令, 比如 no = 0 是电灯的开和关的操作
2121 remoteController .setCommand (0 , lightOnCommand , lightOffCommand );
22-
23- System .out .println ("--------���µƵĿ���ť -----------" );
22+
23+ System .out .println ("--------按下灯的开按钮 -----------" );
2424 remoteController .onButtonWasPushed (0 );
25- System .out .println ("--------���µƵĹذ�ť -----------" );
25+ System .out .println ("--------按下灯的关按钮 -----------" );
2626 remoteController .offButtonWasPushed (0 );
27- System .out .println ("--------���³�����ť -----------" );
27+ System .out .println ("--------按下撤销按钮 -----------" );
2828 remoteController .undoButtonWasPushed ();
29-
30-
31- System .out .println ("=========ʹ��ң�����������ӻ� ==========" );
32-
29+
30+
31+ System .out .println ("=========使用遥控器操作电视机 ==========" );
32+
3333 TVReceiver tvReceiver = new TVReceiver ();
34-
34+
3535 TVOffCommand tvOffCommand = new TVOffCommand (tvReceiver );
3636 TVOnCommand tvOnCommand = new TVOnCommand (tvReceiver );
37-
38- //�����ǵ�ң������������, ���� no = 1 �ǵ��ӻ��Ŀ��صIJ���
37+
38+ //给我们的遥控器设置命令, 比如 no = 1 是电视机的开和关的操作
3939 remoteController .setCommand (1 , tvOnCommand , tvOffCommand );
40-
41- System .out .println ("--------���µ��ӻ��Ŀ���ť -----------" );
40+
41+ System .out .println ("--------按下电视机的开按钮 -----------" );
4242 remoteController .onButtonWasPushed (1 );
43- System .out .println ("--------���µ��ӻ��Ĺذ�ť -----------" );
43+ System .out .println ("--------按下电视机的关按钮 -----------" );
4444 remoteController .offButtonWasPushed (1 );
45- System .out .println ("--------���³�����ť -----------" );
45+ System .out .println ("--------按下撤销按钮 -----------" );
4646 remoteController .undoButtonWasPushed ();
4747
4848 }
4949
50- }
50+ }
0 commit comments