Created
December 13, 2022 23:01
-
-
Save samirsaci/464e50f50618aee89ac4522ca7dc991e 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 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