阅读下列说明和C++代码,回答问题,将解答填入答题纸的对应栏内。
【说明】
某灯具厂商欲生产一个灯具遥控器,该遥控器具有7个可编程的插槽,每个插槽都有开关按钮,对应着一个不同的灯。利用该遥控器能够统一控制房间中该厂商所有品牌灯具的开关,现采用Command(命令)模式实现该遥控器的软件部分。Command模式的类图如下图所示。
【C++代码】
class Light {public: Light(stringname) { /* 代码省略 */ } void on() {/* 代码省略 */ } // 开灯 void off() {/* 代码省略 */ } // 关灯};class Command {public: (1) ;};class LightOnCommand:public Command { // 开灯命令private: Light* light;public: LightOnCommand(Light* light) { this->light=light; } voidexecute() { (2) ; }};class LightOffCommand:public Command { // 关灯命令private: Light *light;public: LightOffCommand(Light* light) { this->light=light; } voidexecute() { (3) ; }};class RemoteControl{ // 遥控器private: Command*onCommands[7]; Command*offCommands[7];public: RemoteControl() { /* 代码省略*/ } voidsetCommand(int slot, Command* onCommand, Command* offCommand) { (4) =onCommand; (5) =offCommand; } voidonButtonWasPushed(int slot) { (6) ; } voidoffButtonWasPushed(int slot) { (7) ; }};int main() { RemoteControl* remoteControl=new RemoteControl(); Light*livingRoomLight=new Light("Living Room"); Light*kitchenLight=new Light("kitchen"); LightOnCommand*livingRoomLightOn=newLightOnCommand(livingRoomLight); LightOffCommand* livingRoomLightOff=newLightOffCommand(livingRoomLight); LightOnCommand*kitchenLightOn=new LightOnCommand(kitchenLight); LightOffCommand* kitchenLightOff=new LightOffCommand(kitchenLight); remoteControl->setCommand(0, livingRoomLightOn, livingRoomLightOff); remoteControl->setCommand(1,kitchenLightOn, kitchenLightOff); remoteControl->onButtonWasPushed(0); remoteControl->offButtonWasPushed(0); remoteControl->onButtonWasPushed(1); remoteControl->offButtonWasPushed(1); /* 其余代码省略 */ return 0;}
(1)virtual void execute()=0
(2)light->on()
(3)light->off()
(4)onCommands[slot]
(5)offCommands[slot]
(6)onCommands[slot]->execute()
(7)offCommands[slot]->execute()
( )is the process of transforming information so it is unintelligible to anyone but the intended recipient.
As each application module is completed,it undergoes( )to ensure that it operates correctly and reliably.
( )algorithm specifies the way to arrange data in a particular order.
After analyzing the source code,( )generates machine instructions that will carry out the meaning of the program at a later time.
( )can help organizations to better understand the information contained within the data and will also help identify the data that is most important to the business and future business decisions.
浏览器开启无痕浏览模式后,( )依然会被保存下来。
下列协议中,不属于TCP/IP协议簇的是( )。
下列传输介质中,带宽最宽、抗干扰能力最强的是( )。
数控编程常需要用参数来描述需要加工的零件的图形。在平面坐标系内,确定一个点需要2个独立的参数,确定一个正方形需要( )个独立的参数。
某书的页码为1,2,3,...,共用数字900个(一个多位数页码包含多个数字),据此可以推断,该书最大的页码为( )。