类 设计pattery策略我想用PHP来实现战略设计模式: interface dummy_function {
public function render();
}
class a implements dummy_function {
public function render() {
echo "class a\n";
// I want
我有一个问题实施策略模式到我的项目。我创建了所有需要的文件,但是我在主要的新调用中遇到错误,因为我似乎无法将策略初始化为我想要的。 Strategy.h /*All the classes that implement a concrete strategy should use this
The AI class will use this file as a concrete strateg
我目前正在学习设计模式。在研究策略模式时,我发现了一些对我来说很陌生的事情。我寻找关于这种模式的讨论,但没有人回答我的问题......我如何实施战略模式,让它变得干净,保持封装并使添加新战略变得容易。在这里解释一下我的问题是,“规范”的战略格局: public interface Strategy {
public void run();
}
public class stratC
给定一个典型的战略格局 class Strategy
{
public:
virtual int execute() const = 0;
}
class StrategyA : public Strategy
{
public:
int execute() const override;
}
class StrategyB : public Strateg
我正在为我的项目使用简单的策略模式。 我需要在某些枚举中添加每个具体的策略接口类以供将来使用。为了方便起见,我使用了一个临时接口,应该在稍后进行替换,而不是实现每个具体的类来完成第一个设计。 这里是简单的代码,我试过了。 public interface Strategy{
public void execute();
}
public interface NeedToImplem