91成人精品一区在线播放,成人毛片在线播放器,国产精品剧情av,日韩尤物在线,亚洲麻豆视频,岛国免费在线,亚洲a欧美

軟題庫 移動APP 掃碼下載APP 隨時隨地移動學習 培訓課程
試卷名稱 2011年下半年程序員考試下午真題試題(案例分析)
考試中心《2011年下半年程序員考試下午真題試題(案例分析)》在線考試
試卷年份2011年下半年
試題題型【分析簡答題】
試題內容

試題六(共15分) 
    閱讀以下說明、圖和Java代碼,填補Java代碼中的空缺(1)—(5),將解答寫在答題紙的對應欄內。  
【說明】  
    已知某公司主要有兩大類耗電資產(Asset):計算機(ComputerAsset)和建筑物(BuildingAsset)。為了節(jié)約能源,通過控制各種電源,將可關閉的房燈、計算機顯示器等在夜間關閉。  
    為了實現上述需求,設計了如下圖所示的類圖,并用下面的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{    
//燈的通用信息:fluorescent / incandescent 等,略 
    BuildingLight(int room Number){  super(roomNumber); } 
}  
class EmergencyLight(1){          /*應急燈,永不關閉*/
    EmergencyLight(int roomNumber){
        super(roomNumber); 
    } 
}  
class RoomLights (2){  
    RoomLights(int roomNumber){ super(roomNumber);}  
    public void powerDown(){  /*關電源,代碼略*/ } 
    public void powerUp(){   /*開電源,代碼略*/ } 
}  
/*ComputerAsset、ComputerCPU和ComputerMonitor代碼略*/ 
public class BuildingManagement{ 
    Asset things[]=new Asset[24];  
    int numItems=0;  
    public void goodNight(){    /*值班員定時“關閉”時調用,關閉可關閉的電源*/
        for(int i=0;i<things.length;i++)
            if(things[i] instanceof (3))
                ((PowerSwitchable)things[i]).powerDown(); 
    }  
    /*goodMorning( )與goodNight( )類似,依次調用powetUp( ),其實現細節(jié)此處略*/ 
    public void add(Asset thing){     /*為建筑添加資產*/
    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房間的應急燈
      b1.add(new ComputerCPU(10104));        //101房間4號桌上的計算機主機
      b1.add(new ComputerMonitor(10104));      //101房間4號桌上的計算機顯示器
      b1.goodNight( ); 
      delete b1;    
    } 
}


相關試題

推薦文章
合作網站內容