-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
39 lines (35 loc) · 1.06 KB
/
index.js
File metadata and controls
39 lines (35 loc) · 1.06 KB
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
// DESAFIO ESCREVENDO CLASSES DE UM JOGO
class heroi {
constructor(nome, idade, tipo) {
this.nome = nome;
this.idade = idade;
this.tipo = tipo;
}
atacou() {
let tiposAtaque = ["magia", "espada", "arte marciais", "shuriken"]
let ataque = "";
if(this.tipo === "mago") {
ataque = tiposAtaque[0]
} else if(this.tipo === "guerreiro") {
ataque = tiposAtaque[1]
} else if(this.tipo === "monge") {
ataque = tiposAtaque[2]
} else if(this.tipo === "ninja") {
ataque = tiposAtaque[3]
}
console.log(`O ${this.tipo} atacou usando ${ataque}`);
}
tipoHeroi() {
if (this.tipo === "mago") {
return "Mago";
} else if (this.tipo === "guerreiro") {
return "Guerreiro";
} else if (this.tipo === "monge") {
return "Monge";
} else if(this.tipo === "ninja"){
return "Ninja";
}
}
}
let heroiJorge = new heroi("Jorge", 35, "guerreiro")
heroiJorge.atacou()