def unload(self, products, warehouse): if not self.is_waiting: counted_products = Counter(products) if not(self.warehouse == warehouse): self.move(warehouse) warehouse.addProducts(counted_products) OrderWriter.write([self.id, "U", warehouse.id, OrderWriter.products_to_string(counted_products)])
def deliver(self, order): if not self.is_waiting: self.products.subtract(order.products) # something for indicating the order is finished OrderWriter.write([ self.id, "D", order.id, OrderWriter.products_to_string(order.products) ])
def unload(self, products, warehouse): if not self.is_waiting: counted_products = Counter(products) if not (self.warehouse == warehouse): self.move(warehouse) warehouse.addProducts(counted_products) OrderWriter.write([ self.id, "U", warehouse.id, OrderWriter.products_to_string(counted_products) ])
def load(self, products, warehouse): if not self.is_waiting: counted_products = Counter(products) if not(self.warehouse == warehouse): self.move(warehouse) total_weight = 0 for product in counted_products: total_weight += product.weight if total_weight <= self.max_load - self.current_load: warehouse.removeProducts(counted_products) OrderWriter.write([self.id, "L", warehouse.id, OrderWriter.products_to_string(counted_products)])
def wait(self, duration): self.is_waiting = True # something to handle time - drone needs to know when to stop waiting OrderWriter.write([self.id, "W", duration]) # Tests # init_w = Warehouse((0,0), [Product(45,12), Product(45,12)], 0) # w = Warehouse((452, 341), [Product(23,10), Product(23,10)], 10) # # d = Drone(0, 200, init_w, [Product(23,10), Product(23,10)], False) # d.load([Product(45,12), Product(45,12)], w) # d.unload([Product(45,12)], w) # # # print(Order((435,445), [Product(23,10)], 10) == Order((435,445), [Product(23,10)], 10)) # # print(Warehouse((435,445), [Product(23,10)], 0) == Warehouse((435,445), [Product(23,10)], 0))
def load(self, products, warehouse): if not self.is_waiting: counted_products = Counter(products) if not (self.warehouse == warehouse): self.move(warehouse) total_weight = 0 for product in counted_products: total_weight += product.weight if total_weight <= self.max_load - self.current_load: warehouse.removeProducts(counted_products) OrderWriter.write([ self.id, "L", warehouse.id, OrderWriter.products_to_string(counted_products) ])
def deliver(self, order): if not self.is_waiting: self.products.subtract(order.products) # something for indicating the order is finished OrderWriter.write([self.id, "D", order.id, OrderWriter.products_to_string(order.products)])