问题 单项选择题

图7-5UML类图所示意的设计模式的意图是()。

A.为特定的客户(或情况)提供特定系列的对象

B.定义一系列的算法并将它们一个个封装起来,使它们可以相互替换

C.将一个复杂对象的构建与它的表示分离,使得同样的构建过程可以创建不同的表示

D.定义一个用于创建对象的接口,让子类决定实例化哪一个类

答案

参考答案:B

解析:

图7-5UML类图所描绘的设计模式中的Strategy(策略)模式。其设计意图是:定义一系列的算法,把它们一个个封装起来,并且使它们可相互替换。换言之,strategy(策略)模式使得算法可独立于使用它的客户而变化。

Abstract,Factory(抽象工厂)模式的设计意图是:为特定的客户(或情况)提供特定系列的对象。

Builder(建造)模式的设计意图是:将一个复杂对象的构建与它的表示分离,使得同样的构建过程可以创建不同的表示。

Factory Method(工厂方法)模式也称为Polymorphic Factory(多态性工厂)模式或Virtual Constructor(虚拟构造器),其设计意图是:定义一个用于创建对象的接口,让子类决定实例化哪一个类。

完形填空
完形填空。
     Mike always loves ships. When he was    1   , he said,"l'm going into the army. "But his eyes were not
   2  ,and he could not get in.
     Then he said,"l'm going to buy a small   3   ,and I'm going to go around the world. "But boats  4   
very expensive,and Mike did not have   5   money.
      But last summer Mike found a swimmg  club(俱乐部)near   6   house.The lessons did not cost very much,and Mike began going to the club at the weekends and    7  Now he is a good swimmer.
      Last week a little boy said to him,"You are a very good swimmer. How did you leam to swim   8  
"Mike said and he smiled,"Whenever I'm in the water,l say to   9  ,There are dangerous fishes in this
area(地区) !'  Then I'm very   10   ,and I try to swim fast. "
( )1. A.dead            
( )2. A.good            
( )3. A.plane            
( )4. A.are              
( )5. A.many            
( )6. A.his              
( )7. A. having meetings
( )8. A.so slowly        
( )9. A.me              
( )10. A.afraid          
B. younger      
B. bad          
B. train        
B. is          
B. much        
B. her          
B. watching TV
B. so fast      
B. myself      
B. busy        
C. older 
C. broken          
C. boat            
C. were            
C. any            
C. him            
C.  having lessons
C. not so fast    
C. him            
C. poor            
D. ill            
D. weak          
D. car            
D. was            
D. few            
D. she            
D. seeing films  
D. not so well    
D. himself        
D. rich          

多项选择题