-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexploding.ts
More file actions
26 lines (23 loc) · 721 Bytes
/
exploding.ts
File metadata and controls
26 lines (23 loc) · 721 Bytes
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 Room from "./room";
import PlainMazeFactory from "./plainmazefactory";
import IMazeFactory from './imazefactory'
class ExplodingRoom extends Room {
constructor(public hasBomb: boolean) {
super();
}
public explode(): void { }
public toString(): string {
return 'ExplodingRoom #' + this.roomID + ' (hasBomb = ' + this.hasBomb + ')'
}
}
class ExplodingRoomFactory extends PlainMazeFactory
implements IMazeFactory // implements the abstract factory
{
private roomCounter: number = 0
public makeRoom(): ExplodingRoom {
this.roomCounter++;
// put a bomb in every other room
return new ExplodingRoom((this.roomCounter % 2) == 0)
}
}
export { ExplodingRoom, ExplodingRoomFactory }