diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..0812991 Binary files /dev/null and b/.DS_Store differ diff --git a/log.txt b/log.txt new file mode 100644 index 0000000..f46dc65 --- /dev/null +++ b/log.txt @@ -0,0 +1,35 @@ +commit 08da4605172acdebe2d143f3119b2fc494e9ec9c +Author: Wind-Explorer +Date: Fri Sep 18 14:40:12 2026 +0800 + + update screenshots + +commit ee697ecd0817cd3844d20091c5d82a76609da6c6 +Author: Wind-Explorer +Date: Fri Sep 18 14:35:08 2026 +0800 + + added modular_auditor.py and updated Dockerfile to use new script + +commit 4bae2ce67d91a3ddf003a7e02694b4ee65d97ea9 +Author: Wind-Explorer +Date: Fri Sep 11 14:20:20 2026 +0800 + + added README with repo link + +commit 692dad6849e6a93c95b23470500e0ec658674e3e +Author: Wind-Explorer +Date: Fri Sep 11 12:34:59 2026 +0800 + + add screenshots + +commit 6fb9105403e08e35766978c7d554c16525382e49 +Author: Wind-Explorer +Date: Fri Sep 11 12:34:27 2026 +0800 + + add dockerfile + +commit 721ad431270886cb85748935e65b90de04001286 +Author: Wind-Explorer +Date: Fri Sep 11 12:21:09 2026 +0800 + + init diff --git a/persist_auditor.py b/persist_auditor.py new file mode 100644 index 0000000..13efc1b --- /dev/null +++ b/persist_auditor.py @@ -0,0 +1,64 @@ +def get_valid_input(): + global failed_attempts + + while True: + user_input = input("Enter stock quantity: ").strip() + + if user_input.lower() == "quit": + return "quit" + + if not user_input.isdigit(): + print("Error: Invalid input. Please enter a non-negative integer.\n") + failed_attempts += 1 + continue + + quantity = int(user_input) + + if quantity < 0: + print("Error: Negative numbers are not allowed.\n") + failed_attempts += 1 + continue + + return quantity + + +def process_delivery(current_total, new_value): + return current_total + new_value + + +def calculate_tax(amount): + return amount * 0.10 + + +def generate_report(total_units, failed_attempts): + print("\n--- Audit Report ---") + print(f"Total Units Processed: {total_units}") + print(f"Failed/Rejected Entries: {failed_attempts}") + + +inventory = 0 +total_units = 0 +failed_attempts = 0 + +print("=== Stock Auditor ===") +print("Type 'quit' to exit.\n") + +while True: + quantity = get_valid_input() + + if quantity == "quit": + break + + tax = calculate_tax(quantity) + + inventory = process_delivery(inventory, quantity) + total_units = process_delivery(total_units, quantity) + + print(f"Stock added. Current inventory: {inventory}") + print(f"Tax on this delivery: ${tax:.2f}\n") + + if inventory > 500: + print(f"ALERT: Overstock detected! Inventory ({inventory}) exceeds 500 units.") + break + +generate_report(total_units, failed_attempts) diff --git a/persistent_auditor.py b/persistent_auditor.py new file mode 100644 index 0000000..6cde9f9 --- /dev/null +++ b/persistent_auditor.py @@ -0,0 +1,72 @@ +def get_valid_input(): + global failed_attempts + + while True: + user_input = input("Enter stock quantity: ").strip() + + if user_input.lower() == "quit": + return "quit" + + if not user_input.isdigit(): + print("Error: Invalid input. Please enter a non-negative integer.\n") + failed_attempts += 1 + continue + + quantity = int(user_input) + + if quantity < 0: + print("Error: Negative numbers are not allowed.\n") + failed_attempts += 1 + continue + + return quantity + + +def process_delivery(current_total, new_value): + return current_total + new_value + + +def calculate_tax(amount): + return amount * 0.10 + + +def generate_report(total_units, failed_attempts): + print("\n--- Audit Report ---") + print(f"Total Units Processed: {total_units}") + print(f"Failed/Rejected Entries: {failed_attempts}") + + +def load_inventory(): + try: + with open("inventory.txt", "r") as inventory_file: + return int(inventory_file.readline().strip()) + except FileNotFoundError: + return 0 + + +inventory = load_inventory() +total_units = 0 +failed_attempts = 0 + +print("=== Stock Auditor ===") +print("Type 'quit' to exit.\n") + +while True: + quantity = get_valid_input() + + if quantity == "quit": + break + + tax = calculate_tax(quantity) + + inventory = process_delivery(inventory, quantity) + total_units = process_delivery(total_units, quantity) + + print(f"Stock added. Current inventory: {inventory}") + print(f"Tax on this delivery: ${tax:.2f}\n") + + if inventory > 500: + print(f"ALERT: Overstock detected! Inventory ({inventory}) exceeds 500 units.") + break + +generate_report(total_units, failed_attempts)