Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- class Contacto:
- def __init__(self, idContacto, nombre):
- self.idContacto = idContacto
- self.nombre = nombre
- return
- def mostrar(self):
- print("Contacto{ id: " + str(self.idContacto) + ", nombre: " + self.nombre + "}")
- return
- class Red:
- def __init__(self, cant):
- self.grafo = ([None] * cant)
- self.contactos = ([None] * cant)
- self.contactos[0] = Contacto("Jair")
- return
- def generarRed(self):
- for i in range(len(self.grafo)):
- self.grafo[i] = ([None] * random.randint(1, 10))
- return
- def mostrarContactos(self):
- for i in self.grafo:
- print("\n/* ===== Contacto ===== */")
- for j in i:
- j.mostrar()
- return
- red = Red(10)
- red.generarRed()
- #red.mostrarContactos()
- #
- #a = Contacto(10, "Jair")
- #b = Contacto(20, "Willi")
- #
- #
- #c = [a, b]
- #
- #c[0].mostrar()
- #c[1].mostrar()
Add Comment
Please, Sign In to add comment