Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from typing import Dict
- from ansi import BRIGHT_YELLOW, BRIGHT_RED, RESET
- import buy
- import deliveries
- import help_menus
- from footer import get_user_choice, invalid_choice
- class InventoryManager:
- """
- Manage drug inventory.
- """
- def __init__(self) -> None:
- self.inventory_data: Dict[str, int] = {}
- def add_to_inventory(self, drug: str, quantity: int) -> None:
- """
- Add a specified quantity of a drug to inventory.
- Raises:
- ValueError: If quantity is negative.
- """
- if quantity < 0:
- raise ValueError("Cannot add a negative quantity to inventory.")
- if drug in self.inventory_data:
- self.inventory_data[drug] += quantity
- else:
- self.inventory_data[drug] = quantity
- def display_inventory(self) -> None:
- """
- Display the inventory menu.
- """
- while True:
- self.print_inventory_header()
- self.display_inventory_list()
- if self.inventory_data:
- for drug, qty in self.inventory_data.items():
- print(f"{drug:<25} {qty:<25}")
- else:
- print(f"{BRIGHT_RED}No drugs in inventory.{RESET}")
- self.display_menu()
- choice = get_user_choice()
- if choice == "B":
- buy.buy_drugs()
- elif choice == "D":
- # Changed from 'deliveries.show_deliveries()' to the correct menu call.
- deliveries.deliveries_menu()
- elif choice == "H":
- help_menus.show_help("INVENTORY")
- elif choice == "X":
- break
- else:
- invalid_choice()
- def print_inventory_header(self) -> None:
- """
- Print the inventory header.
- """
- print(f"\n{BRIGHT_YELLOW}INVENTORY{RESET}\n")
- from header import game_stats
- game_stats.display_header()
- def display_inventory_list(self) -> None:
- """
- Display the title row for the inventory list.
- """
- print(f"{BRIGHT_YELLOW}{'DRUG':<25} {'QUANTITY':<25}{RESET}")
- print("-" * 50)
- def display_menu(self) -> None:
- """
- Display inventory menu options.
- """
- print(f"\n{BRIGHT_YELLOW}B{RESET} - Buy")
- print(f"{BRIGHT_YELLOW}D{RESET} - Deliveries")
- print(f"{BRIGHT_YELLOW}H{RESET} - Help")
- print(f"{BRIGHT_YELLOW}X{RESET} - Back")
Add Comment
Please, Sign In to add comment