-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathApp.ts
34 lines (24 loc) · 745 Bytes
/
App.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
27
28
29
30
31
32
33
34
import { Salesman, SalesLeader, SalesManager, SalesOfficer, SaleHandler } from "./Chain"
export default class ChainExample {
salesDept: SaleHandler
constructor(){
this.salesDept = this.configure()
this.run()
}
configure(): SaleHandler {
let salesman = new Salesman()
let leader = new SalesLeader()
let manager = new SalesManager()
let officer = new SalesOfficer()
salesman.setNext(leader)
leader.setNext(manager)
manager.setNext(officer)
return salesman
}
run(): void {
this.salesDept.handle(500)
this.salesDept.handle(5000)
this.salesDept.handle(20000)
this.salesDept.handle(500000)
}
}