女人久久久www免费人成看片,国内自拍偷拍网,国产一区二区三区免费在线观看,欧美精品三区四区,91久久国产综合久久91,欧美成人精品第一区二区三区 ,美女成人在线观看

軟題庫(kù) 學(xué)習(xí)課程
試卷年份2014年下半年
試題題型【分析簡(jiǎn)答題】
試題內(nèi)容

閱讀下列說(shuō)明和Java代碼,將應(yīng)填入 (n) 處的字句寫(xiě)在答題紙的對(duì)應(yīng)欄內(nèi)。
【說(shuō)明】
某燈具廠商欲生產(chǎn)一個(gè)燈具遙控器,該遙控器具有7個(gè)可編程的插槽,每個(gè)插槽都有開(kāi)關(guān)燈具的開(kāi)關(guān),現(xiàn)采用Command(命令)模式實(shí)現(xiàn)該遙控器的軟件部分。Command模式的類(lèi)圖如圖1-1所示。

【Java代碼】
class Light {
public Light() {}
public Light(String name) { /* 代碼省略 */ }
public void on()  { /* 代碼省略 */ }    // 開(kāi)燈
public void off()  { /* 代碼省略 */ }    // 關(guān)燈
// 其余代碼省略
}
(1)     {
public void execute();
}
class LightOnCommand implements Command { // 開(kāi)燈命令
Light light;
public LightOnCommand(Light light) { this.light=light; }
public void execute() {     (2)    ; }
}
class LightOffCommand implements Command { // 關(guān)燈命令
Light light;
public LightOffCommand(Light light) { this.light=light; }
public void execute(){     (3)    ; }
}
class RemoteControl { // 遙控器
Command[] onCommands=new Command[7];
Command[] offCommands=new Command[7];
public RemoteControl() { /* 代碼省略 */ }
public void setCommand(int slot, Command onCommand, Command offCommand) {
(4)    =onCommand;
(5)    =offCommand;
}
public void onButtonWasPushed(int slot) {
(6)    ;
}
public void offlButtonWasPushed(int slot){
(7)    ;
}
}
class RemoteLoader {
public static void main(String[] args) {
RemoteControl remoteControl=new RemoteControl();
Light livingRoomLight=new Light("Living Room");
Light kitchenLight=new Light("kitchen");
LightOnCommand livingRoomLightOn=new LightOnCommand(livingRoomLight);
LightOffCommand livingRoomLightOff=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.offButtonWasPushed(0);
remoteControl.onButtonWasPushed(1);
remoteControl.offButtonWasPushed(1);
}
}

查看答案

相關(guān)試題

3題: 閱讀下列說(shuō)明和圖,回答問(wèn)題1至問(wèn)題3,將解答填入答題紙的對(duì)應(yīng)欄內(nèi)。
【說(shuō)明】
某公司欲開(kāi)發(fā)一個(gè)管理選民信息的軟件系統(tǒng)。系統(tǒng)的基本需求描述如下:
(1)每個(gè)人(Person)可以是一個(gè)合法選民(Eligible)或者無(wú)效的選民(Ineligible)。
(2)每個(gè)合法選民必須通過(guò)該系統(tǒng)對(duì)其投票所在區(qū)域(即選區(qū),Riding)進(jìn)行注冊(cè)( Registration)。每個(gè)合法選民僅能注冊(cè)一個(gè)選區(qū)。
(3)選民所屬選區(qū)由其居住地址(Address)決定。假設(shè)每個(gè)人只有一個(gè)地址,地址可以是鎮(zhèn)(Town)或者城市(City)。
(4)某些選區(qū)可能包含多個(gè)鎮(zhèn);而某些較大的城市也可能包含多個(gè)選區(qū)。
現(xiàn)采用面向?qū)ο蠓椒▽?duì)該系統(tǒng)進(jìn)行分析與設(shè)計(jì),得到如圖1-1所示的初始類(lèi)圖。

【問(wèn)題1】 (8分)
根據(jù)說(shuō)明中的描述,給出圖1-1中C1~C4所對(duì)應(yīng)的類(lèi)名(類(lèi)名使用說(shuō)明中給出的英文詞匯)。
【問(wèn)題2】(3分)
根據(jù)說(shuō)明中的描述,給出圖1-1中M1~M6處的多重度。
【問(wèn)題3】(4分)
現(xiàn)對(duì)該系統(tǒng)提出了以下新需求:
(1)某些人擁有在多個(gè)選區(qū)投票的權(quán)利,因此需要注冊(cè)多個(gè)選區(qū);
(2)對(duì)手滿足(1)的選民,需要?jiǎng)澏ㄆ洹爸饕幼〉亍?,以確定他們應(yīng)該在哪個(gè)選區(qū)進(jìn)行投票。
為了滿足上述需求,需要對(duì)圖1-1所示的類(lèi)圖進(jìn)行哪些修改?請(qǐng)用100字以內(nèi)文字說(shuō)明。
答案解析與討論:m.xiexiliangjiufa.com/st/3814720120.html

4題: 閱讀下列說(shuō)明和C代碼,回答問(wèn)題1至問(wèn)題3,將解答寫(xiě)在答題紙的對(duì)應(yīng)欄內(nèi)。
【說(shuō)明】
計(jì)算一個(gè)整數(shù)數(shù)組a的最長(zhǎng)遞增子序列長(zhǎng)度的方法描述如下:
假設(shè)數(shù)組a的長(zhǎng)度為n,用數(shù)組b的元素b[i]記錄以a[i](0≤i;其中b[i]滿足最優(yōu)子結(jié)構(gòu),可遞歸定義為:

【C代碼】
下面是算法的C語(yǔ)言實(shí)現(xiàn)。
(1)常量和變量說(shuō)明
a:長(zhǎng)度為n的整數(shù)數(shù)組,待求其最長(zhǎng)遞增子序列
b:長(zhǎng)度為n的數(shù)組,b[i]記錄以a[i](0≤i度,其中0≤ilen:最長(zhǎng)遞增子序列的長(zhǎng)度
i,j:循環(huán)變量
temp:臨時(shí)變量
(2)C程序
#include
int maxL(int*b, int n) {
int i, temp=0;
for(i=0; i if(b[i]>temp)
temp=b[i];
}
return temp;
}
int main() {
int n, a[100], b[100], i, j, len;
scanf("%d", &n);
for(i=0; i scanf("%d", &a[i]);
}
(1)    ;
for(i=1; i for(j=0, len=0;     (2)    ; j++) {
if(    (3)     && len len=b[j];
}
(4)    ;
}
Printf("len:%d\n", maxL(b,n));
printf("\n");
}
【問(wèn)題1】(8分)
根據(jù)說(shuō)明和C代碼,填充C代碼中的空(1)~(4)。
【問(wèn)題2】(4分)
根據(jù)說(shuō)明和C代碼,算法采用了 (5) 設(shè)計(jì)策略,時(shí)間復(fù)雜度為 (6) (用O符號(hào)表示)。
【問(wèn)題3】(3分)
已知數(shù)組a={3,10,5,15,6,8},根據(jù)說(shuō)明和C代碼,給出數(shù)組b的元素值。
答案解析與討論:m.xiexiliangjiufa.com/st/3814829334.html

5題: 閱讀下列說(shuō)明和C++代碼,將應(yīng)填入 (n) 處的字句寫(xiě)在答題紙的對(duì)應(yīng)欄內(nèi)。
【說(shuō)明】
某燈具廠商欲生產(chǎn)一個(gè)燈具遙控器,該遙控器具有7個(gè)可編程的插槽,每個(gè)插槽都有開(kāi)關(guān)按鈕,對(duì)應(yīng)著一個(gè)不同的燈。利用該遙控器能夠統(tǒng)一控制房間中該廠商所有品牌燈具的開(kāi)關(guān),現(xiàn)采用Command(命令)模式實(shí)現(xiàn)該遙控器的軟件部分。Command模式的類(lèi)圖如圖1-1所示。

【C++代碼】
class Light {
public:
Light(string name) { /* 代碼省略 */ }
void on() { /* 代碼省略 */ }    // 開(kāi)燈
void off() { /* 代碼省略 */ }  // 關(guān)燈
};
class Command {
public:
(1)    ;
};
class LightOnCommand:public Command { // 開(kāi)燈命令
private:
Light* light;
public:
LightOnCommand(Light* light) { this->light=light; }
void execute() {     (2)    ; }
};
class LightOffCommand:public Command { // 關(guān)燈命令
private:
Light *light;
public:
LightOffCommand(Light* light) { this->light=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* kitchenLight=new Light("kitchen");
LightOnCommand* livingRoomLightOn=new LightOnCommand(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;
}
答案解析與討論:m.xiexiliangjiufa.com/st/3814921042.html