-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClass.js
45 lines (41 loc) · 1.08 KB
/
Class.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
43
44
45
class Character {
name = '';
role = '';
armor = 0;
damage = 0;
constructor (name, role, armor, damage){
this.name = name;
this.role = role;
this.armor = armor;
this.damage = damage;
}
charArmor () {
console.log(`${this.name} has ${this.armor} armor`);
return this;
}
charDamage () {
console.log(`${this.name} has ${this.damage} damage`);
return this;
}
}
class Mage extends Character {
fly = true;
constructor (name, armor, damage, fly) {
super(name, 'Mage', armor, damage)
this.fly = fly;
}
}
class Support extends Mage {
heal = 0;
constructor (name, armor, damage, fly, heal) {
super (name, armor, damage, fly)
this.heal = heal;
}
}
let gusion = new Character('Gusion', 'Assassin', 400, 100);
let jadokar = new Mage ('Jadokar', 200, 400, true);
let hilos = new Support ('Hilos', 800, 50, true, 500);
jadokar.charArmor().charDamage();
console.log(jadokar);
console.log(hilos);
console.log(gusion);