試題六(共15分) 
    閱讀以下說明、圖和Java代碼,填補(bǔ)Java代碼中的空缺(1)—(5),將解答寫在答題紙的對(duì)應(yīng)欄內(nèi)。  
【說明】  
    已知某公司主要有兩大類耗電資產(chǎn)(Asset):計(jì)算機(jī)(ComputerAsset)和建筑物(BuildingAsset)。為了節(jié)約能源,通過控制各種電源,將可關(guān)閉的房燈、計(jì)算機(jī)顯示器等在夜間關(guān)閉。  
    為了實(shí)現(xiàn)上述需求,設(shè)計(jì)了如下圖所示的類圖,并用下面的Java代碼加以實(shí)現(xiàn)。 
    
【Java代碼】
abstract class Asset{                        /*通用資產(chǎn),基類*/     }
interface PowerSwitchable{                  /*可在夜間關(guān)閉的電源的物體實(shí)現(xiàn)該接口*/  
    public void  powerDown( );        
    public void powerUP( ); 
}   
abstract class BuildingAsset extends Asset{  /*建筑物資產(chǎn)*/  
    protected int room; 
    public BuildingAsset(int room){  this.room=room; } 
}  
abstract class BuildingLight extends BuildingAsset{    
//燈的通用信息:fluorescent / incandescent 等,略 
    BuildingLight(int room Number){  super(roomNumber); } 
}  
class EmergencyLight(1){          /*應(yīng)急燈,永不關(guān)閉*/
    EmergencyLight(int roomNumber){
        super(roomNumber); 
    } 
}  
class RoomLights (2){  
    RoomLights(int roomNumber){ super(roomNumber);}  
    public void powerDown(){  /*關(guān)電源,代碼略*/ } 
    public void powerUp(){   /*開電源,代碼略*/ } 
}  
/*ComputerAsset、ComputerCPU和ComputerMonitor代碼略*/ 
public class BuildingManagement{ 
    Asset things[]=new Asset[24];  
    int numItems=0;  
    public void goodNight(){    /*值班員定時(shí)“關(guān)閉”時(shí)調(diào)用,關(guān)閉可關(guān)閉的電源*/
        for(int i=0;i<things.length;i++)
            if(things[i] instanceof (3))
                ((PowerSwitchable)things[i]).powerDown(); 
    }  
    /*goodMorning( )與goodNight( )類似,依次調(diào)用powetUp( ),其實(shí)現(xiàn)細(xì)節(jié)此處略*/ 
    public void add(Asset thing){     /*為建筑添加資產(chǎn)*/
    things[(4)]=thing; 
    }  
    public static void main(String[ ]args)  { 
      BuildingManagement b1=(5) BuildingManagement( ); 
      b1.add(new RoomLights(101));            //101房間的控制燈
      b1.add(new EmergencyLight(101));         //101房間的應(yīng)急燈
      b1.add(new ComputerCPU(10104));        //101房間4號(hào)桌上的計(jì)算機(jī)主機(jī)
      b1.add(new ComputerMonitor(10104));      //101房間4號(hào)桌上的計(jì)算機(jī)顯示器
      b1.goodNight( ); 
      delete b1;    
    } 
}
							
 
                     10年專注信管,信管教育專注者,信管網(wǎng)優(yōu)勢(shì)
 10年專注信管,信管教育專注者,信管網(wǎng)優(yōu)勢(shì) 免費(fèi)試聽信管網(wǎng)信息系統(tǒng)項(xiàng)目管理師課程
 免費(fèi)試聽信管網(wǎng)信息系統(tǒng)項(xiàng)目管理師課程 全國(guó)前50名高分學(xué)員訪談:董麗(174)、李思...
 全國(guó)前50名高分學(xué)員訪談:董麗(174)、李思... 信息系統(tǒng)項(xiàng)目管理師高端班培訓(xùn)課程
 信息系統(tǒng)項(xiàng)目管理師高端班培訓(xùn)課程 信管老師100小時(shí)直播課程
 信管老師100小時(shí)直播課程 軟考報(bào)名專題(報(bào)名時(shí)間、入口等)
 軟考報(bào)名專題(報(bào)名時(shí)間、入口等) 中級(jí)系統(tǒng)集成項(xiàng)目管理工程師通關(guān)課程
 中級(jí)系統(tǒng)集成項(xiàng)目管理工程師通關(guān)課程 系統(tǒng)規(guī)劃與管理師課程(考試介紹與題型分析)
 系統(tǒng)規(guī)劃與管理師課程(考試介紹與題型分析) 軟題庫(kù):軟考在線題庫(kù)、支持手機(jī)答題
 軟題庫(kù):軟考在線題庫(kù)、支持手機(jī)答題