-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathkitchen.js
38 lines (33 loc) · 980 Bytes
/
kitchen.js
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
35
36
37
38
import {Inject} from 'di';
import {CoffeeMaker} from './coffee_maker/coffee_maker';
import {Skillet} from './skillet';
import {Stove} from './stove';
import {Fridge} from './fridge';
import {Dishwasher} from './dishwasher';
@Inject(CoffeeMaker, Skillet, Stove, Fridge, Dishwasher)
export class Kitchen {
constructor(coffeeMaker, skillet, stove, fridge, dishwasher) {
this.coffeeMaker = coffeeMaker;
this.skillet = skillet;
this.stove = stove;
this.fridge = fridge;
this.dishwasher = dishwasher;
}
makeScrambledEggs() {
console.log('Making some eggs...');
this.skillet.add(this.fridge.getEggs());
this.stove.add(this.skillet);
this.stove.on();
this.stove.off();
console.log('Scrambled eggs are ready.');
}
makeBreakfast() {
// make a cofee
this.coffeeMaker.brew();
// make some eggs
this.makeScrambledEggs();
// clean the dishes
this.dishwasher.add(this.skillet);
this.dishwasher.wash();
}
}