-
Notifications
You must be signed in to change notification settings - Fork 0
/
order.js
42 lines (41 loc) · 875 Bytes
/
order.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
39
40
41
42
class Order {
constructor(id, drink, count) {
this.id = id;
this.drink = drink;
this.count = count;
this.waiting = count;
this.making = 0;
this.complete = 0;
}
getNotComplete() {
return this.waiting + this.making;
}
hasWaiting() {
return this.waiting > 0;
}
hasMaking() {
return this.making > 0;
}
getDrinkName() {
return this.drink.getName();
}
getOneMakingTime() {
return this.drink.getTime();
}
isAllComplete() {
return this.count === this.complete;
}
makingOne() {
if(this.waiting > 0) {
this.waiting--;
this.making++;
}
}
completeOne() {
if(this.making > 0) {
this.making--;
this.complete++;
}
}
}
module.exports = Order;