首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
阅读下列说明和C++代码,将应填入 (n) 处的字句写在答题纸的对应栏内。 【说明】 某灯具厂商欲生产一个灯具遥控器,该遥控器具有7个可编程的插槽,每个插槽都有开关按钮,对应着一个不同的灯。利用该遥控器能够统一控制房间中该厂商所有品牌灯具的开关
阅读下列说明和C++代码,将应填入 (n) 处的字句写在答题纸的对应栏内。 【说明】 某灯具厂商欲生产一个灯具遥控器,该遥控器具有7个可编程的插槽,每个插槽都有开关按钮,对应着一个不同的灯。利用该遥控器能够统一控制房间中该厂商所有品牌灯具的开关
admin
2015-12-01
24
问题
阅读下列说明和C++代码,将应填入 (n) 处的字句写在答题纸的对应栏内。
【说明】
某灯具厂商欲生产一个灯具遥控器,该遥控器具有7个可编程的插槽,每个插槽都有开关按钮,对应着一个不同的灯。利用该遥控器能够统一控制房间中该厂商所有品牌灯具的开关,现采用Command(命令)模式实现该遥控器的软件部分。Command模式的类图如图4—1所示。
【C++代码】
class Light{
public:
Light(string name){/*代码省略*/}
void on(){/*代码省略*/} //开灯
void off(){/*代码省略*/} //关灯
}
class Command{
public:
(1);
);
class LightOnCommand:public Command{//开灯命令
private:
Light*light;
public:
LightOnCommand(Light*light){this一>iight=light;)
Void execute(){(2);)
};
class LightOffCommand:public Command{//关灯命令
private:
Light*iight;
public:
LightOffCommand(Light*light){this一>i ight=light;)
Void execute(){(3);}
};
class RemoteControl(//遥控器
private:
Command*onCommands[7];
Command*offCommands[7];
public:
RemoteControl(){/*代码省略*/)
void setCommand(int slot Command*onCommand,Command*offCommand){
(4)=onCommand;
(5)=offCommand;
}
void onButtonWasPushed(int slot){(6):)
void offButtonwasPushed(int slot){(7):)
);
int main(){
RemoteControl*remoteControl=new RemoteControl();
Light*livingRoomLight=new Light(“Living Room”);
Light*kitchen Light=new Light(“kitchen");
LightOnCommand*IivingRoomLightOn=new LightOnCommand(livingRoomLight):
LightOffCommand*iivingRoomLightOff=new LightOffCommand(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一>off ButtonWasPushed(0);
remoteControl一>onButtonWasPushed(1);
remoteControl一>offButtonWasPushed(1);
/*其余代码省略*/
return0;
}
选项
答案
(1)void execute(){} (2)light一>on() (3)light一>off() (4)onCommands[slot] (5)offCommands[slot] (6)onCommands[slot]一>execute() (7)offCommands[slot]一>execute()
解析
本题考查Command命令模式的概念及应用。Command命令模式是一种对象行为模式。它主要解决的问题是,在软件构建过程中,“行为请求者”与“行为实现者”通常呈现一种“紧耦合”的问题。将一个请求封装为一个对象,从而使你可用不同的请求对客户进行参数化;对请求排队或记录请求日志,以及支持可撤销的操作。
转载请注明原文地址:https://jikaoti.com/ti/dsi7FFFM
本试题收录于:
软件设计师下午应用技术考试题库软考中级分类
0
软件设计师下午应用技术考试
软考中级
相关试题推荐
为了使DNS_Server1能正确解析本地Web站点的域名,需对DNS_Server1中的DNS服务进行配置。在图1所示的对话框中,新建的区域名称是(1);在图2所示的对话框中,添加的新建主机名称为(2),IP地址栏应填入(3)。将DNS_Serve
阅读以下关于动态主机配置协议(DHCP)的说明,回答问题1至问题4。【说明】在小型网络中,IP地址的分配一般都采用静态方式,需要在每台计算机上手工配置网络参数,诸如IP地址、子网掩码、默认网关和DNS等。在大型网络中,采用DHCP完成基本网络配置
下图为RouterB上的路由表信息,写出查询路由表的命令:(1)。该路由器上运行的路由协议为(2)。行政办公楼部门A所属网络地址是(3),部门B所属网络地址是(4)。在主机D上使用命令TracertDNSServer,显示结
阅读以下说明,回答问题1至问题3,将解答填入对应的解答栏内。【说明】某校园网申请到了C类网络地址块202.115.0.0/24~202.115.3.0/24。根据网络规划需求,网络中心、图书馆、教学实验楼以及行政办公楼的各个部门需划分到不同网段。
根据你的网络工程经验,请用250字以内的文字简要描述该21层教学综合大楼网络层次结构设计的要点。(不要求画图)该21层教学综合大楼的部分网络拓扑结构如图1-22所示,其中L3_switch1、L3_switch2为该教学综合大楼的两台核心交换机;Swi
阅读以下有关传统局域网络运行和维护的叙述,将应填入(n)处的字句写在对应栏内。在对网络运行及维护前首先要了解网络,包括识别网络对象的硬件情况、判别局域网的拓扑结构和信道访问方式、确定网络互联以及用户负载等。常见的3种拓扑结构是星形、(1)与(2)拓
阅读以下家庭HFC宽带接入Internet网的技术说明,结合网络连接拓扑图,根据要求回答问题1至问题5。【说明】混合光纤一同轴电缆网(即HFC网)将光纤敷设到小区,再通过光电转换节点,利用CATV的总线式同轴电缆网连接到用户,从而为用户提供Int
在图4-8所示的无线接待室中WLAN采用的体系结构如图4-9所示,请将(1)~(3)空缺处填写完整IEEE802.11定义了无线局域网(WLAN)的两种工作模式,根据图4-8所示的网络拓朴结构可判断出该WLAN的工作模式是(4)。当前WLAN中主要使
在RAS上存在着两个RJ45的端口,分别为Console与AUX,请问这两个端口的用途是什么?(控制在100个字以内)在第4步中,进入虚拟操作台后,在IOS环境下输入了如下的配置,请解释(1)~(4)处的标有下划线部分配置命令的含义(“◇”后为配置内容
阅读以下有关网络设备安装与调试的叙述,分析设备配置文件,回答问题1、问题2和问题3。现以一台远程访问服务器(RemoteAccessServer,RAS)Cisco2509、RJ45为例来说明。第1步,准备安装与调试所需的设备,主要包
随机试题
土地使用权出让的生效要件是什么?
关于肥大,下列描述中正确的有
因实邪结聚,阻滞经络,气血不能外达的病机是
确定低氟区饮水是否加氟的条件因素不包括()
产后出血的处理原则包括
下列说法中错误的是()。
A、 B、 C、 D、 C
甲是某派出所的值班警察,在值班室接到一群众上缴的他人丢失的皮包。甲打开皮包后发现里面有高档手机一部、信用卡若干张、现金数百元,产生非法占有的念头,遂将该皮包内的物品转放进自己的皮包,失主来认领时,仅将空包返还给失主。甲的行为构成()。
文化软实力集中体现了一个国家基于文化而具有的凝聚力和生命力,以及由此产生的吸引力和影响力。提高国家文化软实力要()
Theprisoner______thathehadassaultedapoliceman.
最新回复
(
0
)