#coding=utf-8
import abc
class AbstractFactory(object):
"""抽象工厂
"""
__metaclass__ = abc.ABCMeta
@abc.abstractmethod
def product_car(self):
pass
class MercedesFactory(AbstractFactory):
"""梅赛德斯工厂
"""
def product_car(self):
return Mercedes()
class BMWFactory(AbstractFactory):
"""宝马工厂
"""
def product_car(self):
return BMW()
工厂方法
最新推荐文章于 2024-07-18 15:51:14 发布