Vending Machine Project – Python OOP

I have been working on a vending machine project described below.

After selecting & # 39; b & # 39; In the first menu, I'm having trouble comparing the cost of the selected item with the total amount inside the vending machine (self.total). I have figured out how to reference the selected product through a dictionary (VendingMachine.order_product), however this only works as a string and I cannot subtract the value of the product (product.price) from the self.total – This may be seen at self.total – = {product.price} in VendingMachine.order_product

Once the order has been completed and the product received, I want to subtract 1 product from the item. Stock that can be selected in the first menu in option c – & # 39; Transacciones & # 39 ;. If there are none left in stock, I want to remove the item from the dict using the .remove method I suppose.

I have no coding friends, so it has been difficult to get here! Any comments would be appreciated!

Sorry if I didn't explain it very well.

accepted_coins= (0.05, 0.10, 0.20, 0.50, 1.00, 2.00) 
options = ("a", "b", "c")


class Item:
 def __init__(self, code, name, price, stock):
    self.code = code
    self.name = name
    self.price = price
    self.stock = stock


class VendingMachine:


def __init__(self):
    self.total = 0.00

    self.items = {
       '1' : Item(1, "Tea", 0.50, 10),
       '2' : Item(2, "Coffee", 1.00, 10),
       "3" : Item(3, "Coke", 1.50, 6),
       "4" : Item(4, "Orange Juice", 1.00, 5)
    }



def select_option(self):
    print(" ")
    print("Welcome to My Vending Machine")
    print ("{} Display Products".format(options(0)))
    print ("{} Choose Product".format(options(1)))
    print ("{} Transactions".format(options(2)))
    option = input("Please select option: ")
    if option == options(0):
        VendingMachine.display_items(self)
        VendingMachine.select_option(self)
    elif option == options(1):
        VendingMachine.order_product(self)
    elif option == options(2):
        VendingMachine.display_items(self)
    elif option not in (options):
        print("This option is not recongised")
        VendingMachine.select_option(self)



def display_items(self):
    print (" ")
    print ("All items are currently stocked and available")
    print ("Display items here")



def order_product(self):
    choice = (input("Please insert the item code: "))
    product = self.items(choice)       
    print (f"You have selected {product.name} for ${product.price}. Currently {product.stock} in stock")


    coin = float(input("Please insert your coins: "))
    if float(coin) not in (accepted_coins):
        print ("The Vending Machine accepts only {}" . format(accepted_coins), end = ' ')
    else:
        self.total += coin

    print (f" You have {self.total} in the Machine. You need ${product.price} for {product.name}")

    print("(1) - Confirm")
    print("(2) - Cancel")
    confirm = float(input('Currently there is a total of ${:.2f} in the Machine. Confirm Order?: '.format(self.total)))
    if float(confirm) == 1:
        self.total -= {product.price} #<< HERE IS MY ISSUE, I want to subtract product.price thats referenced above in the sting from the self.total
        print(f'Please take your {product.name} for a total of ${product.price}. Currently there is a total of ${self.total} left in the Vending Machine')
    elif float(confirm) == 2:
        print ("Please take your money. Have a nice Day!")
        self.total = 0.00
        VendingMachine.select_option(self)
    elif float(confirm) != 2:
        print("Incorrect Answer - Please take your money and try again")
        self.total = 0.00
        VendingMachine.order_product(self)


def main():

vending_machine = VendingMachine()
vending_machine.select_option()



return 0


if __name__ == "__main__":
import sys
sys.exit(main())

Accessibility: recent standard for the best touch screen technology? (large screen for ticket vending machine)

We need to order new models of ticket vending machines (for train tickets). We know from our research that our customers complained a lot about the touch screen quality of our current models (e.g. it is not accurate enough when pressing certain elements (or degrades accuracy after a few years), poor display in case of reflection of sunlight, …)
We would like to make sure that our next screens offer a better experience in that matter. But as technology in such an area evolves rapidly, I find it difficult to find recent standards that define what type of technology / screens would make a good bet (in fact, touch accuracy is defined by the technology behind, the screen size, etc.) .
Sure, there are some ISO standards (ISO 9241-9, ISO 9241-3, ISO 9241-5, ISO 9241-7 or ISO 9241-2) but probably everyone has been a bit outdated in that regard. Do you have any experience or source that you would be willing to share about this? Thank you.

How to provide proof of payment to an offline Lightning Network vending machine?

I am considering building a Lightning Network vending machine that is offline but has the ability to create LN invoices and verify payments.

As an example, the scheme has:

  • A vending machine offline.
  • An online node to validate payments.
  • A user (online with a cell phone).

For that there must be:
– A way for the vending machine to provide valid invoices that can be paid to the node online.
– A way for the user to communicate a payment benefit to the vending machine.

Is this currently viable? Is this something that can / should be standardized so that each wallet can implement it?

dnd 5e: What is a balanced version of this magic vending machine?

One of my players (level 7) wants to buy / order a magic vending machine that produces healing potions. I like the idea, but I don't want it to break the game. For 1000-1500gp, what are some reasonable limitations for the item?

Maybe something like non-permanence of potions, or chance fails every time it is invoked (or maybe every time the potion is drunk)?