0

2 つのパターンを入れ子にして、ファクトリ クラスも戦略と呼ぶなど、抽象ファクトリを戦略として使用できるかどうかを知りたいです。

私の質問を説明するために例を挙げました。クラスShoppingMallはコンテキスト クラスになりPizzaStoreますが、問題の抽象ファクトリは、この場合も戦略であると考えます。

// interface of context class, mostly a wrapper
// uses 3 different strategies
interface ShoppingMall
{
    PizzaStore GetPizzaStore();
    ParkingLot GetParkingLot();
    Adverts GetAdverts();

    void CustomerArrives();
}

// abstract factory & strategy interface?
interface PizzaStore 
{
    Pizza CreatePizzaCheese();
    Pizza CreatePizzaVeggie();
    Pizza CreatePizzaClam();
    Pizza CreatePizzaPepperoni();
}

// strategy interface
interface ParkingLot 
{
    void Pay();
}

// strategy interface   
interface Adverts
{
    void CreateSpam();
}

class PizzaStoreChicago implements PizzaStore {}
class PizzaStoreNY implements PizzaStore {}
class PizzaStoreObjectVille  implements PizzaStore {}

class ParkingLotBig   implements ParkingLot {}
class ParkingLotSmall implements ParkingLot {}
class ParkingLotCheap implements ParkingLot {}

class AdvertsAnnoying implements Adverts {}
class AdvertsBoring implements Adverts {}
class AdvertsStupid implements Adverts {}

class ShoppingMallObjectVille implements ShoppingMall {}
class ShoppingMallJavaRanch implements ShoppingMall {}
class ShoppingMallAverage implements ShoppingMall {}
class ShoppingMallOther implements ShoppingMall {}
4

1 に答える 1