Created
December 13, 2022 22:39
-
-
Save samirsaci/76ff5fb1d36f1b98ad334a02c167e27d to your computer and use it in GitHub Desktop.
Digital Twin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Define a Warehouse class to represent a warehouse | |
class Warehouse: | |
def __init__(self, location, capacity): | |
self.location = location | |
self.capacity = capacity | |
self.inventory = {} | |
def add_inventory(self, item, quantity): | |
if item in self.inventory: | |
self.inventory[item] += quantity | |
else: | |
self.inventory[item] = quantity | |
def remove_inventory(self, item, quantity): | |
if item in self.inventory and self.inventory[item] >= quantity: | |
self.inventory[item] -= quantity | |
else: | |
print("Error: Not enough inventory to fulfill order.") | |
# Create a warehouse at location "New York" with a capacity of 100 | |
warehouse = Warehouse("New York", 100) | |
# Add 10 units of item "A" to the warehouse's inventory | |
warehouse.add_inventory("A", 10) | |
# Remove 5 units of item "A" from the warehouse's inventory | |
warehouse.remove_inventory("A", 5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment