Skip to content

Commit 5a42677

Browse files
author
Karan Goel
committed
Product class added.
1 parent b1f704f commit 5a42677

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

Classes/product_inventory.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""
2+
Product Inventory Project - Create an application which manages
3+
an inventory of products. Create a product class which has a
4+
price, id, and quantity on hand. Then create an inventory class
5+
which keeps track of various products and can sum up the inventory
6+
value.
7+
"""
8+
9+
class Product:
10+
11+
def __init__(self, price, pid, qty):
12+
"""
13+
Class constructor that needs a price, a product id,
14+
and quantity.
15+
"""
16+
self.price = price
17+
self.pid = pid
18+
self.qty = qty
19+
20+
def print_product(self):
21+
"""
22+
Prints a single product.
23+
"""
24+
print '%d\t%s\t%.02f each' % (self.pid, self.qty, self.price)
25+
26+
p = Product(1.4, 123, 5)
27+
p.print_product()

0 commit comments

Comments
 (0)