Last active
April 15, 2023 13:10
-
-
Save esilvajr/6029a89f6569262def77d2a0ad0faddb to your computer and use it in GitHub Desktop.
iti_factory_method_sample.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Cliente(): # Product | |
def gerencie(self): | |
raise NotImplementedError | |
class PessoaFisica(Cliente): # ConcreteProduct | |
def gerencie(self): | |
print("Gerenciando pessoas fisicas") | |
class PessoaJuridica(Cliente): # ConcreteProduct | |
def gerencie(self): | |
print("Gerenciando pessoas juridicas") | |
class Factory(): # Creator | |
def factoryMethod(self): | |
raise NotImplementedError | |
class PessoaFisicaFactory(Factory): # ConcreteCreator | |
def factoryMethod(self) -> Cliente: | |
return PessoaFisica() | |
class PessoaJuridicaFactory(Factory): # ConcreteCreator | |
def factoryMethod(self) -> Cliente: | |
return PessoaJuridica() | |
if __name__ == "__main__": # ClientCode | |
pessoa = PessoaFisicaFactory().factoryMethod() | |
pessoa.gerencie() | |
pessoa = PessoaJuridicaFactory().factoryMethod() | |
pessoa.gerencie() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment