コード例 #1
0
while again_choice == 1:
    if book_choice == 1:

        while menu_choice != 4:
            print("Please chose the number to indicate which option you would like to choose")
            print("1. Add inventory")
            print("2. Decrease inventory")
            print("3. Change price")
            print("4. Leave everything how it is")

            menu_choice = int(input("> "))

            if menu_choice == 1:
                print("You chose to add inventory")
                addition = input("How many books did we add: ")
                textbook_1.add_inventory(addition)
                print(textbook_1.quantity_in_inventory)
            elif menu_choice == 2:
                print("You chose to decrease inventory")
                lose = input("How many books did we sell: ")
                textbook_1.decrease_inventory(lose)
                print(textbook_1.quantity_in_inventory)
            elif menu_choice == 3:
                print("You chose to change the price")
                print(f"The current price is: ${textbook_1.price}")
                textbook_1.price = float(input("The price is now: $"))
            elif menu_choice == 4:
                print("You chose to leave this book as it is.")
            else:
                print("Invalid choice")
    elif book_choice == 2:
コード例 #2
0
    print("Please make a choice from the menu:")
    print("1. Add to inventory")
    print("2. Deduct from inventory")
    print("3. Change the price of the book")
    print("4. Change the year the book was published")
    print("5. End program, Have a good day!")

    menu_choice = int(input())
    # Break down which book is chosen in each function
    if menu_choice == 1:
        print("Book 1 or Book 2?")
        choice = int(input())
        if choice == 1:
            qty = int(
                input("How much would you like to add to the inventory?"))
            book1.add_inventory(qty)
            print("The quantity in the inventory is now" + ' ' +
                  str(book1.quantity) + "\n\n")
        else:
            print("The quantity in book 2 is now" + ' ' + str(book2.quantity) +
                  "\n\n")
    elif menu_choice == 2:
        print("Book 1 or 2?")
        choice = int(input())
        if choice == 1:
            qty = int(input("How many would you like to remove?"))
            result = book1.deducting_inventory(qty)
        elif choice == 2:
            qty = int(input("How many would you like to remove?"))
            result = book2.deducting_inventory(qty)
            if result == 0:
コード例 #3
0
ファイル: driver.py プロジェクト: fullere/textbook
        print(book1.description())
    elif choice == "2":
        print(book2.description())
    else:
        print("Bye")
# add or remove stock. adds or removes from current stock
elif choose == "3":
    print(f"Update inventory for:\n{title} [1]\n{title2} [2]")
    choice = input("> ")
    if choice == "1":
        print(f"For {title}:\nAdd inventory [1]\nDeduct inventory [2]")
        choice1 = input("> ")
        if choice1 == "1":
            new_stock = input("New incoming stock\n> ")
            new_stock = int(new_stock)
            inven = book1.add_inventory(new_stock)
            print(inven)
        elif choice1 == "2":
            lost = input("Out-going stock\n> ")
            lost = int(lost)
            inven = book1.deduct_inventory(lost)
            print(inven)
        else:
            print("Bye")
    if choice == "2":
        print(f"For {title2}:\nAdd inventory [1]\nDeduct inventory [2]")
        choice1 = input("> ")
        if choice1 == "1":
            new_stock = input("New incoming stock\n> ")
            new_stock = int(new_stock)
            inven = book2.add_inventory(new_stock)