class IWeapon(object):
def info(self):
raise NotImplementedError
class Sword(IWeapon):
def info(self):
print("This cold weapon is Sword")
class Knigfe(IWeapon):
def info(self):
print("This cold weapon is Knigfe")
#------------------------------------------------------
class IFactory(object):
def create_weapon(self):
raise NotImplementedError
class SwordFactory(IFactory):
def create_weapon(self):
return Sword()
class KnigfeFactory(IFactory):
def create_weapon(self):
return Knigfe()
#------------------------------------------------------
def main():
swordFactory = SwordFactory()
knigfeFactory = KnigfeFactory()
sword = swordFactory.create_weapon()
knigfe = knigfeFactory.create_weapon()
sword.info()
knigfe.info()
if __name__ == "__main__":
main()