Skip to content

Instantly share code, notes, and snippets.

@samirsaci
Created December 13, 2022 23:01
Show Gist options
  • Save samirsaci/464e50f50618aee89ac4522ca7dc991e to your computer and use it in GitHub Desktop.
Save samirsaci/464e50f50618aee89ac4522ca7dc991e to your computer and use it in GitHub Desktop.
Digital Twin
# Define a Store class to represent a store
class Store:
def __init__(self, location, inventory):
self.location = location
self.inventory = inventory
def place_order(self, item, quantity):
if item in self.inventory and self.inventory[item] >= quantity:
self.inventory[item] -= quantity
print("Order fulfilled.")
else:
print("Error: Not enough inventory to fulfill order.")
# Create a store at location "New York" with 10 units of item "A" in inventory
store = Store("New York", {"A": 10})
# Place an order for 5 units of item "A"
store.place_order("A", 5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment