Skip to content

Commit

Permalink
Merge pull request #3513 from mikelm2020/miguellopezmdev
Browse files Browse the repository at this point in the history
Miguellopezmdev
  • Loading branch information
Roswell468 authored May 8, 2024
2 parents a4fd0e2 + e924296 commit db3a4a2
Show file tree
Hide file tree
Showing 2 changed files with 245 additions and 0 deletions.
91 changes: 91 additions & 0 deletions Roadmap/08 - CLASES/python/mikelm2020.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Clases
class Store:
def __init__(self, name):
self.name = name
self.items = []

def add_item(self, name, price):
self.items.append({"name": name, "price": price})

def stock_price(self):
total = 0
for item in self.items:
total += item["price"]
return total


# Extra
class Stack:
def __init__(self):
# Crea una pila vacía
self.items = []

def introduce(self, element):
# Agrega el elemento element a la pila
self.items.append(element)

def recover(self):
# Devuelve el elemento tope y lo elimina
# Si la pila está vacía levanta una excepción
try:
return self.items.pop()
except IndexError:
raise ValueError("La pila está vacía")

def is_empty(self):
# Devuelve True si la pila esta vacía
return self.items == []

def size(self):
return len(self.items)

def content(self):
return print(self.items)


class Queue:
def __init__(self):
# Crea una cola vacía
self.items = []

def introduce(self, element):
# Agrega el elemento element a la cola
self.items.append(element)

def recover(self):
# Devuelve el primer elemento y lo elimina
# Si la cola está vacía levanta una excepción
try:
return self.items.pop(0)
except IndexError:
raise ValueError("La cola está vacía")

def is_empty(self):
# Devuelve True si la cola esta vacía
return self.items == []

def size(self):
return len(self.items)

def content(self):
return print(self.items)


if __name__ == "__main__":
store = Store("Test")
store2 = Store("Amazon")
store2.add_item("Keyboard", 100)

stack = Stack()
for number in range(1, 10):
stack.introduce(number)
stack.recover()
stack.content()
print(f"El tamaño de la pila es: {stack.size()}")

queue = Queue()
for number in range(1, 10):
queue.introduce(number)
queue.recover()
queue.content()
print(f"El tamaño de la cola es: {queue.size()}")
154 changes: 154 additions & 0 deletions Roadmap/09 - HERENCIA/python/mikelm2020.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
import uuid


# Superclase animal y subclases perro y gato
class Animal:
def __init__(self, name, breed):
self.name = name
self.breed = breed

def sound_of_animal(self):
pass


class Dog(Animal):
def sound_of_animal(self):
return print("Guau Guau")


class Cat(Animal):
def sound_of_animal(self):
return print("Miau Miau")


# Extra
# Jerarquía
class Employees:
employees_subordinates = []

def __init__(self, name):
self.id = uuid.uuid4()
self.name = name

def add_subordinate(self, id, name, boss):
self.employees_subordinates.append({"id": id, "name": name, "boss": boss})

def subordinates(self, boss):
subordinates_list = [
element
for element in self.employees_subordinates
if element["boss"] == boss
]
return print(subordinates_list)


class Managers(Employees):
def organize(self):
print("El Gerente esta organizando una junta...")

def hire(self):
print("El Gerente esta contratando personal")

def to_plan(self):
print("El Gerente esta planificando una estrategía para obtener más clientes")


class ProjectManagers(Employees):
def lead(self):
print("El Gerente de Proyecto esta dirigiendo al equipo de desarrollo")

def define_objectives(self):
print(
"El Gerente de Proyecto esta definiendo los objetivos para el backend del proyecto"
)

def to_motivate(self):
print("El Gerente de Proyecto esta motivando a los desarrolladores")


class Developers(Employees):
technological_stack = []

def __init__(self, name, role):
super().__init__(name)
self.role = role

def program(self):
print("El pogramador esta programando en su lenguaje favorito")

def add_technology(self, technology):
self.technological_stack.append(technology)

def get_technological_stack(self):
print(self.technological_stack)

def role(self):
print(f"El programador es: {self.role}")


if __name__ == "__main__":
dog = Dog(name="Boby", breed="Pastor aleman")
dog.sound_of_animal()
cat = Cat(name="Mishi", breed="Siames")
cat.sound_of_animal()

manager = Managers("Raul Jimenez")
project_manager1 = ProjectManagers("Saul Najera")
project_manager2 = ProjectManagers("Leticia Olmedo")
backend_1 = Developers("Miguel Angel López", "Desarrollador Backend")
backend_2 = Developers("Romina Palafox", "Desarrollador Backend")
backend_3 = Developers("Alma Benavides", "Desarrollador Backend")
frontend_1 = Developers("Luis Mendoza", "Desarrollador Frontend")
frontend_2 = Developers("Ramiro Gutierrez", "Desarrollador Frontend")
frontend_3 = Developers("Stefania Riquelme", "Desarrollador Frontend")
devops_1 = Developers("Ramiro Corona", "Devops")
devops_2 = Developers("Reina Camacho", "Devops")

manager.add_subordinate(project_manager1.id, project_manager1.name, boss=manager.id)
manager.add_subordinate(project_manager2.id, project_manager2.name, boss=manager.id)
print(f"Los subordinados del Gerente {manager.name} son: ")
manager.subordinates(manager.id)
project_manager1.add_subordinate(
backend_3.id,
backend_3.name,
boss=project_manager1.id,
)
project_manager1.add_subordinate(
frontend_1.id,
frontend_1.name,
boss=project_manager1.id,
)
project_manager1.add_subordinate(
frontend_2.id,
frontend_2.name,
boss=project_manager1.id,
)
project_manager1.add_subordinate(
devops_1.id,
devops_1.name,
boss=project_manager1.id,
)
print(f"Los subordinados del Gerente de Proyecto 1 {project_manager1.name} son: ")
project_manager1.subordinates(project_manager1.id)
project_manager2.add_subordinate(
backend_1.id,
backend_1.name,
boss=project_manager2.id,
)
project_manager2.add_subordinate(
backend_2.id,
backend_2.name,
boss=project_manager2.id,
)
project_manager2.add_subordinate(
frontend_3.id,
frontend_3.name,
boss=project_manager2.id,
)
project_manager2.add_subordinate(
devops_2.id,
devops_2.name,
boss=project_manager2.id,
)
print(f"Los subordinados del Gerente de Proyecto 2 {project_manager2.name} son: ")
project_manager2.subordinates(project_manager2.id)

0 comments on commit db3a4a2

Please sign in to comment.