Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2017
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. class Perrito:
  2. def __init__(self, nombre):
  3. self.nombre= nombre
  4. self.conocidos= []
  5.  
  6. def __str__(self):
  7. return "{}".format(self.nombre)
  8.  
  9. def conocer(self, humano):
  10. (self.conocidos).append(humano.nombre)
  11. print("Mi nombre es {}, un gusto conocerte {}".format(self.nombre,humano.apodo))
  12.  
  13. def saludar(self, humano):
  14. if humano.nombre in self.conocidos:
  15. print("Hola",humano.apodo)
  16. else:
  17. print("Grr, {} no es bienvenido".format(humano.nombre))
  18.  
  19.  
  20. class Humano:
  21. def __init__(self, nombre, apodo):
  22. self.nombre= nombre
  23. self.apodo= apodo
  24. def __str__(self):
  25. return "{}".format(self.nombre)
  26.  
  27.  
  28. entrada = input()
  29. humanos=[]
  30. while not entrada=='fin':
  31. entrad= entrada.split(" ")
  32. if entrad[0]=="Perrito":
  33. perrito= Perrito(entrad[1])
  34. if entrad[0]=="Humano":
  35. humano= Humano(entrad[1],entrad[2])
  36. humanos.append(humano)
  37. if entrad[0]=="Conoce":
  38. for i in humanos:
  39. if i.nombre== entrad[1]:
  40. nuevoperrito=i
  41. perrito.conocer(nuevoperrito)
  42. if entrad[0]=="Saluda":
  43. for i in humanos:
  44. if i.nombre== entrad[1]:
  45. nuevoperrito=i
  46. perrito.saludar(nuevoperrito)
  47.  
  48. entrada = input("")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement