Untitled
class QRCodeSystem: def __init__(self): self.user_qr_data = {} def generate_qr_code(self, user_id): # Generate a QR code for a user qr_code_data = f"User: {user_id}" return qr_code_data def register_user_qr_code(self, user_id): # Register the user and their QR code qr_code = self.generate_qr_code(user_id) self.user_qr_data[user_id] = qr_code return qr_code def confirm_delivery(self, user_id, scanned_qr_code): # Confirm delivery by checking the scanned QR code against the registered user's code if user_id in self.user_qr_data and scanned_qr_code == self.user_qr_data[user_id]: return True else: return False # Example Usage: qr_system = QRCodeSystem() # Registering a user and generating their QR code user_id = "123" user_qr_code = qr_system.register_user_qr_code(user_id) print(f"User QR Code: {user_qr_code}") # Simulating a delivery confirmation scanned_code = "User: 123" delivery_confirmed = qr_system.confirm_delivery(user_id, scanned_code) if delivery_confirmed: print("Delivery Confirmed!") else: print("Delivery Not Confirmed. Invalid QR Code.")
Leave a Comment