-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
42 lines (36 loc) · 968 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
class Heroi {
constructor(nome, idade, tipo) {
this.nome = nome;
this.idade = idade;
this.tipo = tipo;
}
atacar() {
let ataque;
switch (this.tipo) {
case "mago":
ataque = "usou magia";
break;
case "guerreiro":
ataque = "usou espada";
break;
case "monge":
ataque = "usou artes marciais";
break;
case "ninja":
ataque = "usou shuriken";
break;
default:
console.log("Tipo de herói inválido");
return;
}
console.log(`o ${this.tipo} atacou usando ${ataque}`);
}
}
const heroi1 = new Heroi("Lancelot", 35, "guerreiro");
const heroi2 = new Heroi("Merlin", 400, "mago");
const heroi3 = new Heroi("Sun Wukong", 500, "monge");
const heroi4 = new Heroi("Naruto", 17, "ninja");
heroi1.atacar();
heroi2.atacar();
heroi3.atacar();
heroi4.atacar();