Atualizar sistema.ts
This commit is contained in:
parent
1320a6ca27
commit
a630e5ee4d
18
sistema.ts
18
sistema.ts
|
@ -11,7 +11,7 @@ let contadorId = 1;
|
|||
function mostrarMenu(): void {
|
||||
console.log(`
|
||||
Sistema Gerenciador de Séries
|
||||
=============================
|
||||
|
||||
1. Criar
|
||||
2. Listar
|
||||
3. Atualizar
|
||||
|
@ -22,11 +22,11 @@ function mostrarMenu(): void {
|
|||
|
||||
function obterEntradaTexto(mensagem: string): string {
|
||||
let entrada = prompt(mensagem) || "";
|
||||
while (entrada.replace(/\s/g, "") === "") {
|
||||
while (!entrada.trim()) {
|
||||
console.log("Entrada inválida. Por favor, tente novamente.");
|
||||
entrada = prompt(mensagem) || "";
|
||||
}
|
||||
return entrada;
|
||||
return entrada.trim();
|
||||
}
|
||||
|
||||
function obterEntradaNumero(mensagem: string): number {
|
||||
|
@ -59,7 +59,7 @@ function criarSerie(): void {
|
|||
}
|
||||
|
||||
function listarSeries(): void {
|
||||
if (!series[0]) {
|
||||
if (series.length === 0) {
|
||||
console.log("Nenhuma série cadastrada.");
|
||||
return;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ function listarSeries(): void {
|
|||
}
|
||||
|
||||
function atualizarSerie(): void {
|
||||
if (!series[0]) {
|
||||
if (series.length === 0) {
|
||||
console.log("Nenhuma série cadastrada.");
|
||||
return;
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ function atualizarSerie(): void {
|
|||
}
|
||||
|
||||
function excluirSerie(): void {
|
||||
if (!series[0]) {
|
||||
if (series.length === 0) {
|
||||
console.log("Nenhuma série cadastrada.");
|
||||
return;
|
||||
}
|
||||
|
@ -110,11 +110,7 @@ function excluirSerie(): void {
|
|||
return;
|
||||
}
|
||||
|
||||
for (let i = index; i < series.length - 1; i++) {
|
||||
series[i] = series[i + 1];
|
||||
}
|
||||
series.pop();
|
||||
|
||||
series.splice(index, 1);
|
||||
console.log("Série excluída com sucesso!");
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue