问题 单项选择题

某软件公司现欲开发一款飞机飞行模拟系统,用于模拟不同种类飞机的飞行特征与起飞特征。为支持将来模拟更多种类的飞机,采用()设计的类图如图所示。在图中,类Aircraft描述了抽象的飞机,类FlyBehavior与TakeOffBehavior分别用于表示抽象的飞行行为与起飞行为,类SubSonicFly与SuperSonicFly分别描述亚音速飞行和超音速飞行的行为,类VerticalTakeOff与LongDistanceTakeOff分别描述垂直起飞与长距离起飞的行为。|

 

A.Bridge模式

B.Composite模式

C.Observer模式

D.Strategy模式

答案

参考答案:D

解析:

Strategy(策略)模式的设计意图是使得算法可独立于使用它的客户而变化。依题意,为支持将来模拟更多种类的飞机,该飞机飞行模拟系统采用策略设计模式(Strategy)设计的类图如图3所示。在图3中,AirCraft为抽象类,描述了抽象的飞机,而类Helicopter、AirPlane、Fighter和Harrier分别描述具体的飞机种类,方法fly()和takeOff()分别表示不同飞机都具有的飞行特征和起飞特征;类FlyBehavior与TakeOffBehavior为抽象类,分别用于表示抽象的飞行行为与起飞行为;类SubSonicFly与SuperSonicFly分别描述亚音速飞行和超音速飞行的行为;类VerticalTakeOff与LongDistanceTakeOff分别描述垂直起飞与长距离起飞的行为。

Bridge(桥接)模式的设计意图是将抽象部分与现实部分分离,使得它们的两部分可以独立地变化。

Composite(组合)模式的设计意图是将对象组合成树型结构以表示“部分一整体”的层次结构。

Observer(观察者)模式的设计意图是定义对象间的一种一对多的依赖关系,当一个对象的状态发生改变时,所有依赖于它的对象都将得到通知并被自动更新。

阅读理解

阅读理解。

     Ellen Parker was worried about her health. She could not walk very quickly and it was difficult for her

to climb stairs. She was soon out of breath."I suppose I had better go to the doctor." she thought. She went

to the doctor and told him her problem. "I'm not at all surprised." he said, "I know what your problem is."

He examined her and then gave her some advice. "If you don't do what I say, Mrs. Parker," he said, "You

will have a heart attack. It could kill you."

     Ellen was very worried as she left the doctor's. She knew that she had to take his advice but that it would

not be easy and it would take time.

     The next day she went shopping. The first shop she went into was a butcher shop.

     "I'd like ten pounds of steak, please." she said.

     "Certainly, madam." the butcher replied and went into the cold room and found a large piece of steak. He

brought the huge piece of meat back into the shop and placed it on the scale.

     "That's just ten pounds." he said.

     "That's big enough." Mrs. Parker said.

     The butcher worked out the price. "At $4.99 a pound that will be $49.90, please. Would you like me to

cut it up into smaller pieces for you?"

     "Oh, I don't want to buy the meat." Mrs. Parker said.

     "If you don't want to buy it," the butcher replied angrily, "Why did you ask me to get it for you?"

     "My doctor told me that I am too heavy and have to lose ten pounds. I wanted to see what ten pounds of

meat looked like."

1. Why did Ellen Parker visit the doctor? [ ]

A. She had a heart attack.

B. She had a problem with her health.

C. She was unhappy about her weight.

D. She could not sleep well.

2. Why did Ellen Parker ask for ten pounds of steak? [ ]

A. She wanted to buy some for dinner.

B. She wanted to lose weight.

C. Her doctor had told her to eat steak.

D. She wanted to see what ten pounds of meat looked like.

单项选择题