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