Untitled

 avatar
unknown
plain_text
2 years ago
874 B
5
Indexable
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" )
Editor is loading...