Skip to content

Commit 1975eaa

Browse files
committed
mouredev#7 - TypeScript
1 parent 67b43de commit 1975eaa

File tree

1 file changed

+37
-3
lines changed

1 file changed

+37
-3
lines changed

Roadmap/07 - PILAS Y COLAS/typescript/RicJDev.ts

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,53 @@ queue.shift()
2626
console.log('Después de eliminar un elemento:', queue)
2727

2828
//EXTRA
29-
import * as readline from 'readline'
29+
import * as readline from 'node:readline/promises'
3030

3131
const rl = readline.createInterface({
3232
input: process.stdin,
3333
output: process.stdout,
3434
})
3535

36-
//Sistema de navegacion
36+
//Sistema de navegación
3737
function browser(): void {
38-
const stack = []
38+
const pagesStack: string[] = []
39+
40+
function menu(): void {
41+
if (pagesStack.length > 0) {
42+
console.log(`\nActualmente estas en ${pagesStack[pagesStack.length - 1]}`)
43+
} else {
44+
console.log('\nEstas en la pagina de inicio')
45+
}
46+
47+
rl.question(
48+
'Elige una opcion\n1. Avanzar\n2. Retroceder\n3. Salir del navegador\nIr a otra pagina '
49+
).then((answer) => {
50+
if (answer === '1') {
51+
menu()
52+
} else if (answer === '2') {
53+
pagesStack.pop()
54+
menu()
55+
} else if (answer === '3') {
56+
console.log('\nSaliendo del navegador...')
57+
printer()
58+
} else {
59+
pagesStack.push(answer)
60+
menu()
61+
}
62+
})
63+
}
64+
65+
menu()
3966
}
4067

68+
browser()
69+
4170
//Impresora compartida
4271
function printer(): void {
4372
const queue = []
73+
74+
console.log('Hola')
75+
rl.close()
76+
77+
function menu() {}
4478
}

0 commit comments

Comments
 (0)