Siemka
Mam taki kod:
from menu import Menu, UserChoice, wait_menu, quit_menu, do_nothing_choice
from shop.shop import Shop
def list_products(shop: Shop):
if shop.available_products:
print("Available products:")
for idx, product in enumerate(shop.available_products):
print(f"{idx}) {product.name}")
else:
print("No such any products")
wait_menu()
def add_product(shop: Shop):
# TODO: add_product functionality passdef search_products(shop: Shop): passdef remove_prpoduct(shop: Shop): passdef main() -> None:
shop = Shop()
main_menu = Menu('Main menu', items=(
UserChoice('Product list', lambda: list_products(shop)),
UserChoice('Shopping cart', do_nothing_choice),
UserChoice('Your orders', do_nothing_choice),
UserChoice('Quit', quit_menu)
))
main_menu.loop()
if __name__ == '__main__':
main()
Czy jest sens zrobić z funkcji add_product()
, search_products()
itd. osobną klasę o nazwie ShopUI
?
Sorry za lamerskie pytanie ale dopiero się uczę