-
Notifications
You must be signed in to change notification settings - Fork 1
/
distributor.py
38 lines (27 loc) · 1.26 KB
/
distributor.py
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
# -------------------------------------------------------
# This file contains and defines the Distributor class.
# -------------------------------------------------------
from supplyChainActor import SupplyChainActor
class Distributor(SupplyChainActor):
def __init__(self, incomingOrdersQueue, outgoingOrdersQueue, incomingDeliveriesQueue, outgoingDeliveriesQueue):
# Initializes the Distributor object in its initial state
# by calling parent constructor.
super().__init__(incomingOrdersQueue, outgoingOrdersQueue,
incomingDeliveriesQueue, outgoingDeliveriesQueue)
return
def TakeTurn(self, weekNum):
#The steps for taking a turn are as follows:
#RECEIVE NEW DELIVERY FROM FACTORY
self.ReceiveIncomingDelivery() #This also advances the queue!
#RECEIVE NEW ORDER FROM WHOLESALER
self.ReceiveIncomingOrders() #This also advances the queue!
#PREPARE DELIVERY
if weekNum <= 4:
self.PlaceOutgoingDelivery(4)
else:
self.PlaceOutgoingDelivery(self.CalcBeerToDeliver())
#PLACE ORDER
self.PlaceOutgoingOrder(weekNum)
#UPDATE COSTS
self.costsIncurred += self.CalcCostForTurn()
return