Skip to content

Commit 8e5036d

Browse files
committed
message
1 parent e711636 commit 8e5036d

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

Inventory Management System.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
class Product:
2+
def __init__(self, name, category, supplier, quantity):
3+
self.name = name
4+
self.category = category
5+
self.supplier = supplier
6+
self.quantity = quantity
7+
8+
def update_stock(self, amount):
9+
self.quantity += amount
10+
11+
class Category:
12+
def __init__(self, name):
13+
self.name = name
14+
self.products = []
15+
16+
def add_product(self, product):
17+
self.products.append(product)
18+
19+
class Supplier:
20+
def __init__(self, name, contact):
21+
self.name = name
22+
self.contact = contact
23+
24+
def supply_product(self, product, quantity):
25+
product.update_stock(quantity)
26+
27+
class Stock:
28+
def __init__(self):
29+
self.inventory = {}
30+
31+
def add_product(self, product):
32+
self.inventory[product.name] = product
33+
34+
def generate_report(self):
35+
return {name: product.quantity for name, product in self.inventory.items()}
36+
37+
# Example usage
38+
supplier1 = Supplier("ABCSuppliers", "123-456-789")
39+
category1 = Category("Electronics")
40+
41+
product1 = Product("Laptop", category1, supplier1, 50)
42+
category1.add_product(product1)
43+
44+
stock = Stock()
45+
stock.add_product(product1)
46+
47+
supplier1.supply_product(product1, 20)
48+
print(stock.generate_report())

0 commit comments

Comments
 (0)