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