题目内容

试题六(共15分)
阅读以下说明和Java代码,填补Java代码中的空缺(1)~(5),将解答写在答题纸的对应栏内。
【说明】
已知某公司主要有两大类耗电资产(Asset):计算机(ComputerAsset)和建筑物(Building Asset)。为了节约能源,通过控制各种电源,将可关闭的房灯、计算机显示器等在夜间关闭。
为了实现上述需求,设计了如图6-1所示的类图,并用下面的Java代码加以实现。
【Java代码】
abstract class Asset{ /*通用资产,基类*/}
interface PowerSwitchable{ /*可在夜间关闭电源的物体实现该接口*/
public void powerDown();
public void powerUp();
}
abstract class BuildingAsset extends Asset{/*建筑物资产*/
protected int room;
public BuildingAsset(int room){ this.room= room; }
}
abstract class BuildingLight extends BuildingAsset{
//灯的通用信息:flourescent/incandescent等,略
BuildingLight(int roomNumber){ super(roomNumber);}
}
classEmergencyLight (1) {/*应急灯,永不关闭*/
EmergencyLight(int roomNumber){
super(roomNumber);
}
}
class RoomLights (2) {
RoomLights(int roomNumber){ super(roomNumber); }
public void powerDown(){ /*关电源,代码略*/}
public void powerUp(){/*开电源,代码略*/}
}
/*ComputerAsset、 Computer CPU和Computer Monitor代码略*/
public class BuildingManagement{
Asset things[]= new Asset[24];
int numltems=0;
public void goodNight(){/*值班员定时“关闭”时调用,关闭可关闭的电源*/
for (int i=0; i<things.length; i++)
if(things[i] instanceof (3) )
((PowerSwitchable)things[i]).powerDown();
}
/*goodMorning()与goodNight()类似,依次调用powerUp(),其实现细节此处略*/
public void add(Asset thing){ /*为建筑添加资产*/
things[ (4) ]=thing;
}
public static void main(String[] args){
BuildingManagementbl= (5) BuildingManagement();
bl.add(new RoomLights(101)); //101房间的控制灯
bl.add(new EmergencyLight(101)); //101房间的应急灯
bl.add(new ComputerCPU(10104));//101房间4号桌上的计算机主机
bl.add(new ComputerMonitor(10104)); // 101房间4号桌上的计算机显示器
bl.goodNight();
}
}

查看答案
更多问题

SECTION A COMPOSITION (35 MIN)
Some people say that physical exercise should be a required part of every school day. Other people believe that students should spend the whole school day on academic studies. Which opinion do you agree with?
Write on ANSWER SHEET TWO a composition of about 200 words on the following topic:
Physical Exercise Should (Not) Be Done in School
You are to write in three parts:
In the first part, state your point of view on physical exercise in school.
In the second part, give some specific reasons to support your view.
In the last part, bring what you have written to a natural conclusion or a summary.
Marks will be awarded for content, organization, grammar and appropriateness. Failure to follow the above instructions may result in a loss of marks.

假如你是团长带团去山东参加农产品展销,你会怎么组织好这次活动?另外请问你需要重点注意哪些方面?

他能成功的更为重要的机会是,他在浙江创业,而不是北京或其他地方。
(根据资料三进行分析)

如何让基层干部不吃亏?

答案查题题库