-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclasseobjeto.js
37 lines (28 loc) · 953 Bytes
/
classeobjeto.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
class dataOfHero{
constructor(nameOfHero, classOfHero, ageOfHero, attackOfHero){
this.nameOfHero = nameOfHero
this.classOfHero = classOfHero
this.ageOfHero = ageOfHero
this.attackOfHero = attackOfHero
}
show(){
switch(this.classOfHero) {
case ("Mago"):
this.attackOfHero = "Usando a magia";
break
case ("Guerreiro"):
this.attackOfHero = "Usando espada";
break
case ("Monge"):
this.attackOfHero = "Usando artes marciais";
break
case ("Ninja"):
this.attackOfHero = "Usando shuriken"
break
}
console.log(`O ${this.nameOfHero} da classe ${this.classOfHero} tem ${this.ageOfHero} e atacou ${this.attackOfHero}`)
console.log(`O ${this.classOfHero} atacou ${this.attackOfHero}`)
}
}
let hero = new dataOfHero ("Debug", "Ninja", "15years");
hero.show()