-
-
Notifications
You must be signed in to change notification settings - Fork 86
Expand file tree
/
Copy pathclient.ts
More file actions
21 lines (16 loc) · 514 Bytes
/
Copy pathclient.ts
File metadata and controls
21 lines (16 loc) · 514 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Singleton Use Case Example Code
import {Game1} from './game1'
import {Game2} from './game2'
import {Game3} from './game3'
// The Client
// Despite all games instantiating a leaderboard, they all point
// to the same memory object since the leaderboard is a singleton.
const GAME1 = new Game1()
GAME1.addWinner(2, 'Cosmo')
const GAME2 = new Game2()
GAME2.addWinner(3, 'Sean')
const GAME3 = new Game3()
GAME3.addWinner(1, 'Emmy')
GAME1.leaderboard.print()
GAME2.leaderboard.print()
GAME3.leaderboard.print()