-
-
Notifications
You must be signed in to change notification settings - Fork 79
/
Copy pathlion.ts
26 lines (22 loc) · 820 Bytes
/
lion.ts
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
import IProteus from './iproteus'
import Leopard from './leopard'
import Serpent from './serpent'
export default class Lion implements IProteus {
// Proteus in the form of a Lion
name = 'Lion'
tellMeTheFuture(): void {
// Proteus will change to something random
if (Math.floor(Math.random() * 2)) {
Object.assign(this, new Serpent())
this.tellMeTheFuture = Serpent.prototype.tellMeTheFuture
this.tellMeYourForm = Serpent.prototype.tellMeYourForm
} else {
Object.assign(this, new Leopard())
this.tellMeTheFuture = Leopard.prototype.tellMeTheFuture
this.tellMeYourForm = Leopard.prototype.tellMeYourForm
}
}
tellMeYourForm(): void {
console.log(`I am the form of ${this.name}`)
}
}