Compare commits
3 Commits
745a3e2df8
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 675c25373b | |||
| 5f96674692 | |||
| 2f5c37d84d |
@@ -0,0 +1,2 @@
|
||||
git config --global user.email "you@example.com"
|
||||
git config --global user.name "Your Name"
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"imports": {
|
||||
"readline-sync": "npm:readline-sync@^1.4.10"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"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"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,20 @@
|
||||
class Personagem{
|
||||
nome: string;
|
||||
raro: boolean;
|
||||
num_constelaçao: number;
|
||||
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(){
|
||||
@@ -29,8 +41,7 @@ function main(){
|
||||
}
|
||||
}
|
||||
}
|
||||
function create(){
|
||||
console.log("Criando. . .");
|
||||
function create(nome: string, raro: boolean, best_const: number){
|
||||
}
|
||||
|
||||
function read(){
|
||||
@@ -45,4 +56,6 @@ function del(){
|
||||
console.log("Deletando. . .");
|
||||
}
|
||||
|
||||
|
||||
|
||||
main()
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
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() {
|
||||
|
||||
}
|
||||
|
||||
function del() {
|
||||
|
||||
}
|
||||
|
||||
main();
|
||||
Reference in New Issue
Block a user