Skip to content

Commit af50b26

Browse files
committed
Hacking The Future
1 parent 21eb259 commit af50b26

File tree

5 files changed

+73
-0
lines changed

5 files changed

+73
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
class Biblioteca:
2+
def __init__(self, nombre):
3+
self.nombre = nombre
4+
self._libros = []
5+
6+
def consultar_nombre_biblioteca(self):
7+
return self.nombre
8+
9+
def agregar_libro(self, libro):
10+
self._libros.append({
11+
libro.titulo,
12+
libro.autor,
13+
libro.cantidad_de_paginas,
14+
libro.genero,
15+
libro.sinopsis
16+
})
17+
18+
def consultar_libros(self):
19+
return self._libros
20+
21+
def consultar_libro(self, id):
22+
return self._libros[id]
23+
24+
def quitar_libro(self, id):
25+
self._libros.pop(id)

Desarrollo/06_Biblioteca/Libro.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class Libro:
2+
def __init__(self, titulo, autor, cantidad_de_paginas, genero, sinopsis):
3+
self.titulo = titulo
4+
self.autor = autor
5+
self.cantidad_de_paginas = cantidad_de_paginas
6+
self.genero = genero
7+
self.sinopsis = sinopsis
1.28 KB
Binary file not shown.
526 Bytes
Binary file not shown.

Desarrollo/06_Biblioteca/main.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
from Biblioteca import Biblioteca
2+
from Libro import Libro
3+
4+
if __name__ == '__main__':
5+
ejecutar = True
6+
7+
while(ejecutar):
8+
print("- - - B I B L I O T E C A S - - -")
9+
opcion = int(input("¿Qué vas a hacer?:\n1-Crear Biblioteca\n2-Agregar libro\n3-Ver catalogo\n4-Quitar Libro\n5-Salir\n:"))
10+
11+
if opcion == 1:
12+
nombre = input("Nombre de la biblioteca: ")
13+
biblioteca = Biblioteca(nombre)
14+
15+
print("Se creo la biblioteca: {}".format(biblioteca.consultar_nombre_biblioteca))
16+
17+
elif opcion == 2:
18+
titulo = input("Titulo: ")
19+
autor = input("Autor: ")
20+
cantidad_de_paginas = input("Paginas: ")
21+
genero = input("Genero: ")
22+
sinopsis = input("Sinopsis: ")
23+
24+
libro = Libro(titulo, autor, cantidad_de_paginas, genero, sinopsis)
25+
biblioteca.agregar_libro(libro)
26+
27+
elif opcion == 3:
28+
print("Catalogo de libros: ")
29+
for i in biblioteca.consultar_libros():
30+
print(i)
31+
32+
elif opcion == 4:
33+
indice = input("Id del libro a eliminar: ")
34+
biblioteca.quitar_libro(indice)
35+
36+
elif opcion == 5:
37+
print("Gracias por visitar {}".format(biblioteca.consultar_nombre_biblioteca))
38+
ejecutar = False
39+
40+
else:
41+
print("Opcion incorrecta")

0 commit comments

Comments
 (0)