Untitled

mail@pastecode.io avatar
unknown
plain_text
8 months ago
874 B
2
Indexable
Never
class Item:
    def __init__(self,name,price,quantity):
        self.name=name
        self.price=price
        self.quantity=quantity
        self.intro()



    def intro(self):
        inventory = [ Item('item1',2.3,90),
	      Item('item2',3.2,20),
              Item('item3',4.5,70),
              Item('item4',7.9,30),
              Item('item5',5.7,60)]

    def show_inv(self):
        for value in self.inventory:
            print(value)
        print()

    def add(self):
        self.name = input("Enter the name ")
        self.price=float(input("Enter the price "))
        self.quantity=int(input("Enter the quantity"))
        item = Item(name,price,quantity)
        self.inventory.append(item)
        #print(f"{name} {price} {} ".format(self.name,self.price,self.quantity))
        print(f"{self.name} add to your inventory" )