Skip to content

Commit 8da988f

Browse files
committed
Colores para la salida de test
1 parent 9ed5a55 commit 8da988f

File tree

8 files changed

+22
-13
lines changed

8 files changed

+22
-13
lines changed
309 Bytes
Binary file not shown.
590 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

engine/arbol.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from engine.nodo import Nodo
2+
from engine.colors import colors
23

34
class Arbol:
4-
# Funciones privadas
5+
56
def __init__(self, dato):
67
self.raiz = Nodo(dato)
78

@@ -45,23 +46,21 @@ def __buscar(self, nodo, busqueda):
4546
else:
4647
return self.__buscar(nodo.derecha, busqueda)
4748

48-
# Funciones públicas
49-
5049
def agregar(self, dato):
5150
self.__agregar_recursivo(self.raiz, dato)
5251

5352
def inorden(self):
54-
print("Imprimiendo árbol inorden: ")
53+
print(colors.RED + "Imprimiendo árbol inorden: " + colors.RESET)
5554
self.__inorden_recursivo(self.raiz)
5655
print("")
5756

5857
def preorden(self):
59-
print("Imprimiendo árbol preorden: ")
58+
print(colors.YELLOW +"Imprimiendo árbol preorden: " + colors.RESET)
6059
self.__preorden_recursivo(self.raiz)
6160
print("")
6261

6362
def postorden(self):
64-
print("Imprimiendo árbol postorden: ")
63+
print(colors.CYAN +"Imprimiendo árbol postorden: " + colors.RESET)
6564
self.__postorden_recursivo(self.raiz)
6665
print("")
6766

engine/colors.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class colors:
2+
RED = '\033[91m'
3+
GREEN = '\033[92m'
4+
YELLOW = '\033[93m'
5+
BLUE = '\033[94m'
6+
MAGENTA = '\033[95m'
7+
CYAN = '\033[96m'
8+
WHITE = '\033[97m'
9+
RESET = '\033[0m'

engine/nodo.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
class Nodo:
22
def __init__(self, dato):
3-
# "dato" puede ser de cualquier tipo, incluso un objeto si se sobrescriben los operadores de comparación
43
self.dato = dato
54
self.izquierda = None
65
self.derecha = None

main.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
from engine.arbol import Arbol
2+
from engine.colors import colors
23

3-
cantidad = input("Ingresa la cantidad de elementos a ingresar: ")
4+
cantidad = input(colors.YELLOW + "Ingresa la cantidad de elementos: " + colors.RESET)
45

56
for i in range(int(cantidad)):
67
if (i==0):
7-
nombre = input("Ingresa el elemento raiz: ")
8+
nombre = input(colors.GREEN + "Ingresa el elemento raiz: " + colors.RESET)
89
arbol = Arbol(nombre)
910
else:
10-
print(f'[Elemento {i}]')
11-
nombre = input("Ingresa el nombre: ")
11+
print(colors.GREEN + f'[Elemento {i}]'+ colors.RESET)
12+
nombre = input(colors.RED + "Ingresa el nombre: " + colors.RESET)
1213
arbol.agregar(nombre)
1314

1415
print('...\n')

test.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from engine.arbol import Arbol
2+
from engine.colors import colors
23

34
lista_nombres = ['emma', 'olivia', 'isabella', 'sofia', 'emily', 'talulah', 'candela']
45

@@ -10,8 +11,8 @@
1011
arbol.agregar("talulah")
1112
arbol.agregar("candela")
1213

13-
print(f'Nombres agregados: {lista_nombres}\n')
14-
print('...Corriendo test\n')
14+
print(colors.GREEN + f'Nombres agregados: {lista_nombres}\n' + colors.RESET)
15+
print(colors.GREEN + '...Corriendo test\n' + colors.RESET)
1516
arbol.preorden()
1617
arbol.inorden()
1718
arbol.postorden()

0 commit comments

Comments
 (0)