问题 单项选择题

The more he knows about his new colleague, ______.

A.the much he likes to work with him

B.he likes to work with him more

C.the more he likes to work with him

D.the more does he like to work with him

答案

参考答案:C

解析: 英语中,前后两句都以比较级开头,The more…,the more…,意为“越……越……”,如:The harder you work,the more progress you will make. 工作越努力,进步就越多。

填空题

阅读下列说明和Java代码,将应填入 (n) 处的字句写在对应栏内。

[说明]

已知某企业欲开发一个家用电器遥控系统,即用户使用一个遥控器即可控制某些家用电器的开与关。遥控器如图18-13所示。该遥控器共有4个按钮,编号分别是0~3,按钮0和2能够遥控打开电器1和电器2,按钮1和3则能遥控关闭电器1和电器2。由于遥控系统需要支持形式多样的电器,因此,该系统的设计要求具有较高的扩展性。现假设需要控制客厅电视和卧室电灯,对该遥控系统进行设计所得类图如图18-14所示。

在图18-14中,类RomoteController的方法onPressButton(int button)表示当遥控器按键按下时调用的方法,参数为按键的编号;Command接N中的On()和off()方法分别用于控制电器的开与关;Light中的mrnLight(int degree)方法用于调整电灯灯光的强弱,参数degree值为0时表示关灯,值为100时表示开灯,并且将灯光亮度调整到最大;TV中的setChannel(int channel)方法表示设置电视播放的频道,参数channel值为0时表示关闭电视,值为1时表示打开电视并将频道切换为第1频道。

[Java代码]

class Light //电灯类

public void turnLight(int degree)//调整灯光亮度,0表示关灯,100表示亮度最大

class TV//电视机类

Public void setChannel(int channel)//0表示关机,1表示开机并切换到第1频道

interface Command//抽象命令类

void on();

void off();

class RemoteController //遥控器类

protected Command[]commands=new Command[4];

//遥控器有4个按钮,按照编号分别对应4个Command对象

public void onPressButton(int button)

//按钮被按下时执行命令对象中的命令

if(button % 2==0)commands[button].on();

else commands[button].off();

public void setCommand(int button,Command command)

(1) =command;//设置每个按钮对应的命令对象

class LightCommand implements Command //电灯命令类

protected Light light; //指向要控制的电灯对象

public void on()light.turnLight(100);;

public void off()light. (2) :;

public LightCommand(Light light)this.light=light;;

class TVCommand implements Command//电视机命令类

protected Tv tv; //指向要控制的电视机对象

public void on()(tv. (3) ;;

public void off()tv.setChannel(0);;

public TVCommand(TV tv)(this.tv=tv;;

public class rs

public static void main(String[]args)

Light light=new Light();TV tv=new TV(); //创建电灯和电视对象

LightCommand lightCommand=new LightCommand(light);

TVCommand tvCommand=new TVCommand(tv);

RemoteController remoteControllet=new RemoteController();

//设置按钮和命令对象

remoteController.setCommand(0, (4)

…//此处省略设置按钮1、按钮2和按钮3的命令对象代码

本题中,应用命令模式能够有效让类 (5) 和类 (6) 、类 (7) 之间的耦合性降至最小。

(3)处填()。

判断题