Guest User

Untitled

a guest
Nov 13th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. import random
  2.  
  3. class Contacto:
  4. def __init__(self, idContacto, nombre):
  5. self.idContacto = idContacto
  6. self.nombre = nombre
  7.  
  8. return
  9.  
  10. def mostrar(self):
  11. print("Contacto{ id: " + str(self.idContacto) + ", nombre: " + self.nombre + "}")
  12. return
  13.  
  14. class Red:
  15. def __init__(self, cant):
  16. self.grafo = ([None] * cant)
  17. self.contactos = ([None] * cant)
  18.  
  19. self.contactos[0] = Contacto("Jair")
  20.  
  21. return
  22.  
  23.  
  24. def generarRed(self):
  25. for i in range(len(self.grafo)):
  26. self.grafo[i] = ([None] * random.randint(1, 10))
  27.  
  28. return
  29.  
  30.  
  31. def mostrarContactos(self):
  32. for i in self.grafo:
  33. print("\n/* ===== Contacto ===== */")
  34.  
  35. for j in i:
  36. j.mostrar()
  37.  
  38. return
  39.  
  40. red = Red(10)
  41. red.generarRed()
  42. #red.mostrarContactos()
  43. #
  44. #a = Contacto(10, "Jair")
  45. #b = Contacto(20, "Willi")
  46. #
  47. #
  48. #c = [a, b]
  49. #
  50. #c[0].mostrar()
  51. #c[1].mostrar()
Add Comment
Please, Sign In to add comment