Compare commits

..

No commits in common. "5f966746923c009a8c98ebc6a890808708027f53" and "745a3e2df8a69d321530b3b16aab47522be53503" have entirely different histories.

5 changed files with 3 additions and 176 deletions

View File

@ -1,2 +0,0 @@
git config --global user.email "you@example.com"
git config --global user.name "Your Name"

View File

@ -1,5 +0,0 @@
{
"imports": {
"readline-sync": "npm:readline-sync@^1.4.10"
}
}

View File

@ -1,16 +0,0 @@
{
"version": "4",
"specifiers": {
"npm:readline-sync@^1.4.10": "1.4.10"
},
"npm": {
"readline-sync@1.4.10": {
"integrity": "sha512-gNva8/6UAe8QYepIQH/jQ2qn91Qj0B9sYjMBBs3QOB8F2CXcKgLxQaJRP76sWVRQt+QU+8fAkCbCvjjMFu7Ycw=="
}
},
"workspace": {
"dependencies": [
"npm:readline-sync@^1.4.10"
]
}
}

View File

@ -1,20 +1,8 @@
class Personagem{
nome: string;
raro: boolean;
best_const: number;
constructor(nome: string, raro: boolean, best_const: number){
this.nome = nome;
this.raro = raro;
this.best_const = best_const;
}
num_constelaçao: number;
}
const personagens: Personagem[] = [
new Personagem("Xiangling", false, 4),
new Personagem("Xingqiu", false, 3),
new Personagem("Dehya", true, 5)
]
function main(){
@ -41,7 +29,8 @@ function main(){
}
}
}
function create(nome: string, raro: boolean, best_const: number){
function create(){
console.log("Criando. . .");
}
function read(){
@ -56,6 +45,4 @@ function del(){
console.log("Deletando. . .");
}
main()

137
index1.ts
View File

@ -1,137 +0,0 @@
class Personagem {
nome: string;
raro: boolean;
best_const: number;
constructor(nome: string, raro: boolean, best_const: number) {
this.nome = nome;
this.raro = raro;
this.best_const = best_const;
}
}
const personagens: Personagem[] = [
new Personagem("Xiangling", false, 4),
new Personagem("Xingqiu", false, 3),
new Personagem("Dehya", true, 5)
];
function main() {
const menuPrincipal = `
1. Criar
2. Listar
3. Atualizar
4. Excluir
5. Sair
Selecione uma opção: `;
let option: number;
while (true) {
option = parseInt(prompt(menuPrincipal) || '5');
if (option === 5) break;
if (option === 1) {
create();
} else if (option === 2) {
read();
} else if (option === 3) {
update();
} else if (option === 4) {
del();
} else {
alert("Opção inválida, tente novamente.");
}
}
}
function create() {
const nome = prompt("Digite o nome do personagem: ");
const raro = confirm("O personagem é raro? (OK para Sim, Cancelar para Não): ");
const best_const = parseInt(prompt("Digite o melhor constelação (1-6): ") || '1');
if (nome && best_const >= 1 && best_const <= 6) {
const novoPersonagem = new Personagem(nome, raro, best_const);
personagens.push(novoPersonagem);
alert(`Personagem ${nome} foi criado com sucesso!`);
} else {
alert("Entrada inválida. Tente novamente.");
}
}
function read() {
if (personagens.length === 0) {
alert("Nenhum personagem na lista.");
} else {
let list = "Listando Personagens...\n";
personagens.forEach((personagem, index) => {
list += `${index + 1}. Nome: ${personagem.nome}, Raro: ${personagem.raro ? "Sim" : "Não"}, Constelação: ${personagem.best_const}\n`;
});
alert(list);
}
}
function update() {
if (personagens.length === 0) {
alert("Nenhum personagem para atualizar.");
return;
}
let list = "Escolha um personagem para atualizar:\n";
personagens.forEach((personagem, index) => {
list += `${index + 1}. ${personagem.nome}\n`;
});
const index = parseInt(prompt(list) || '0') - 1;
if (index < 0 || index >= personagens.length) {
alert("Índice inválido.");
return;
}
const nome = prompt(`Novo nome para ${personagens[index].nome} (deixe vazio para não alterar): `);
if (nome) {
personagens[index].nome = nome;
}
const raro = confirm(`O personagem ${personagens[index].nome} é raro? (OK para Sim, Cancelar para Não): `);
personagens[index].raro = raro;
const best_const = parseInt(prompt(`Nova constelação para ${personagens[index].nome} (1-6): `) || '1');
if (best_const >= 1 && best_const <= 6) {
personagens[index].best_const = best_const;
alert(`Personagem ${personagens[index].nome} atualizado com sucesso!`);
} else {
alert("Constelação inválida.");
}
}
function del() {
if (personagens.length === 0) {
alert("Nenhum personagem para excluir.");
return;
}
let list = "Escolha um personagem para excluir:\n";
personagens.forEach((personagem, index) => {
list += `${index + 1}. ${personagem.nome}\n`;
});
const index = parseInt(prompt(list) || '0') - 1;
if (index < 0 || index >= personagens.length) {
alert("Índice inválido.");
return;
}
const confirmacao = confirm(`Tem certeza que deseja excluir ${personagens[index].nome}?`);
if (confirmacao) {
personagens.splice(index, 1);
alert("Personagem excluído com sucesso!");
} else {
alert("Exclusão cancelada.");
}
}
main();