The strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.
see SimUDuck app. for reference.
below you'll find a mess of classes and interface for an action adventure game.You'll find classes for game characters along with classes for weapon behaviors the characters can use int the game. Each character can make use of one weapon at a time, but can change weapons at any time during the game. Your job is to sort it all out...
Your task:
1 arrange the classes
2 Identify one abstract class, one interface and eight classes
3 Draw arrows between classes
a Draw this kind of arrow for inheritance ("extends"). ------|>
b Draw this kind of arrow for interface ("implements"). - - - - -|>
c Draw this kind of arrow for "HAS-A" --------->
4 put method setWeapon() into right class.
分享到:
相关推荐
在策略模式(Strategy Pattern)中,一个类的行为或其算法可以在运行时更改。这种类型的设计模式属于行为型模式。 在策略模式中,我们创建表示各种策略的对象和一个行为随着策略对象改变而改变的 context 对象。...
前端大厂最新面试题-Strategy Pattern
定义一系列的算法,把它们一个个封装起来,并且使它们可相互替换。本模式使得算法的变化可独立于使用它的客户。
NULL 博文链接:https://bossshit.iteye.com/blog/715672
主要介绍了C#策略模式(Strategy Pattern),以一个简单的实例讲述了C#策略模式的实现方法,包括策略模式的用途以及具体实现方法,需要的朋友可以参考下
Head.First设计模式中的The Factory Pattern(工厂模式)ppt
1、策略模式STRATEGY PATTERN 2、代理模式PROXY PATTERN 3、单例模式SINGLETON PATTERN 4、多例模式MULTITION PATTERN 5、工厂方法模式FACTORY METHOD PATTERN 6、抽象工厂模式ABSTRACT FACTORY PATTERN 7、门面模式...
strategy-pattern-in-unity
备忘录模式(Memento Pattern) 策略模式(Strategy Pattern) 抽象工厂模式(Abstract Factory Pattern) 代理模式(Proxy Pattern) 单例模式(Singleton Pattern) 迭代器模式(Iterator Pattern) 访问者模式(Visitor ...
处理对象的多种状态及其相互转换——状态模式(五) 处理对象的多种状态及其相互转换——状态模式(六) 策略模式-Strategy Pattern 算法的封装与切换——策略模式(一) 算法的封装与切换——策略模式(二) 算法的...
6. 策略模式 (Strategy Pattern) 7. 适配器模式 (Adapter Pattern) 8. 模板方法模式 (Template Pattern) 9. 建造者模式 (Builder Pattern) 10. 原型模式 (Prototype Pattern) 11. 组合模式 (Composite ...
策略模式[STRATEGY PATTERN] 代理模式[PROXY PATTERN] 单例模式[SINGLETON PATTERN] 多例模式[MULTITION PATTERN] 工厂方法模式[FACTORY METHOD PATTERN] 抽象工厂模式[ABSTRACT FACTORY PATTERN] 门面模式[FACADE ...
策略模式(Strategy Pattern) 模板模式(Template Pattern) 访问者模式(Visitor Pattern) 4. J2EE 模式 MVC 模式(MVC Pattern) 业务代表模式(Business Delegate Pattern) 数据访问对象模式(Dao ...
创建型: 1. 单件模式(Singleton Pattern) 2. 抽象工厂(Abstract Factory) 3. 建造者模式(Builder) 4.... 策略模式(Strategy Pattern) 22. 访问者模式(Visitor Pattern) 23. 状态模式(State Pattern)
Strategy pattern implemented
创建型: 1. 单件模式(Singleton Pattern) 2. 抽象工厂(Abstract Factory) 3.... 4.... 5.... 6. 适配器模式(Adapter ... 策略模式(Strategy Pattern) 22. 访问者模式(Visitor Pattern) 23. 状态模式(State Pattern)
C#设计模式(23种设计模式) 1. 单件模式(Singleton Pattern) 2. 抽象工厂(Abstract Factory) ...21. 策略模式(Strategy Pattern) 22. 访问者模式(Visitor Pattern) 23. 状态模式(State Pattern)
创建型模式用来处理对象的创建过程,主要包含以下5种设计模式: 工厂方法模式(Factory Method ... 策略模式(Strategy Pattern) 模板方法模式(Template Method Pattern) 访问者模式(Visitor Pattern)
创建型: 1. 单件模式(Singleton Pattern) 2. 抽象工厂(Abstract Factory) ... 策略模式(Strategy Pattern) 22. 访问者模式(Visitor Pattern) 23. 状态模式(State Pattern) @Author kwming
设计模式(22)-Strategy Pattern 设计模式(21)-Template Method Pattern 设计模式(20)-Visitor Pattern 设计模式(19)-Observer Pattern 设计模式(18)-Command Pattern 设计模式(17)-Chain of ...