-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProduct.py
More file actions
40 lines (31 loc) · 1.52 KB
/
Product.py
File metadata and controls
40 lines (31 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
class Product:
""" Initialize the variables product_name and product_price."""
""" It accepts an argument for product_name and product_price"""
""" The __ allows these variables to be only used inside class (private variables)"""
def __init__(self):
self.__product_name = ''
self.__product_price = 0
self.__product_quantity = 0
""" The set_product method sets the product_name attribute"""
def set_product_name(self, product_name):
self.__product_name = product_name
""" The get_product_name returns the product_name attribute"""
def get_product_name(self):
return self.__product_name
"""" The set_products_price sets the product_price attribute"""
def set_product_price(self, product_price):
self.__product_price = product_price
""" The get_product_price returns the product_price attribute"""
def get_product_price(self):
return self.__product_price
""" The calculate_tax returns the tax rate of 8.25% on the product"""
def subtotal(self):
return 0.0825 * Product.get_product_price(self)
"""" The get_total_price returns the tax of each product plus the price of the product"""
def get_total_price(self):
return round(Product.get_product_price(self) + Product.calculate_tax(self), 2)
"""Returns the objects state as a string"""
def __str__(self):
return "The total price with tax for {} is: ${} \n".format(
Product.get_product_name(self),
Product.get_total_price(self))