-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
48 lines (45 loc) · 1.22 KB
/
script.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
46
47
48
class Ninja{
constructor(name, health){
this.name = name;
this.health = health;
this.speed = 3;
this.strength = 3;
}
sayName(){
console.log(`My name is ${this.name}, you have killed my father. Prepare to die.`);
}
showStats(){
console.log(`Name: ${this.name} Strength: ${this.strength} Speed: ${this.speed} Health: ${this.health}`);
}
drinkSake(){
this.health += 10;
}
}
class Sensei extends Ninja{
constructor(name, health){
super(name, health);
this.wisdom = 10;
this.strength = 10;
this.speed = 10;
this.health = 200;
}
showStats(){
console.log(`Name: ${this.name} Strength: ${this.strength} Speed: ${this.speed} Health: ${this.health} Wisdom: ${this.wisdom}`);
}
speakWisdom(){
super.drinkSake();
console.log("Gentlemen! It is not the flag that moves. It is not the wind that moves. It is your mind that moves.");
}
}
const ryan = new Ninja("Ryan", 100);
ryan.sayName();
ryan.showStats();
ryan.drinkSake();
ryan.showStats();
const nick = new Sensei("Nick", 200);
nick.sayName();
nick.showStats();
nick.drinkSake();
nick.showStats();
nick.speakWisdom();
nick.showStats();