Skip to content

Commit

Permalink
Adding the Factory method design pattern in Portuguese
Browse files Browse the repository at this point in the history
  • Loading branch information
João Victor Bravo authored and João Victor Bravo committed Oct 14, 2022
1 parent d533d53 commit 091b8b3
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Creational/Factory-Method-PT[BR]/factory_method.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class animals():
class galinha():
info = "Isso é uma galinha"
class cachorro():
info = "Isso é um cachorro"
class pato():
info = "isso é um pato"
def fabricar_animais(tipo):
if tipo == "galinha":
return animals.galinha
elif tipo == "cachorro":
return animals.cachorro
elif tipo == "pato":
return animals.pato
else:
raise AssertionError("Tipo de animal não existe")
lista =[]
while True:
info = input("Qual animal você quer na sua fazenda?\n")
animal = fabricar_animais(info)
lista.append(animal.info)
print(lista)
11 changes: 11 additions & 0 deletions Creational/Factory-Method-PT[BR]/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This is a code of Factory Method

##### This code is written in portuguese, directly from a design pattern subject of my college.

##### Run code

python3 factory_method.py

##### Usage

Just type the name of one of the classes, and then the code will iterate and will work just like an usual factory method code.

0 comments on commit 091b8b3

Please sign in to comment.