-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
29 lines (22 loc) · 818 Bytes
/
main.py
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
# Import the libraries
from item import Item
from phone import Phone
# Instantiate a list of Item() objects reading from the csv file
Item.instantiate_from_csv("items.csv")
print(Item.all)
# Item() class methods
item1 = Item("Monitor", 400, 3)
print(f"Total price is {item1.calculate_total_price()}")
# Apply price increment (changes the price attribute)
item1.apply_increment(0.2)
print(f"Item price is {item1.price}")
# Apply new discount (without changing the price attribute)
item1.discount_rate = 0.5
print(f"Price after discount is {item1.apply_discount()}")
print(f"Item price is {item1.price}")
# Phone() class methods
phone1 = Phone("iPhone13", 1300)
# Inherit from item() parent class
print(phone1.all)
# Access the broken_phone attribute
print(f"The number of broken phone is {phone1.broken_phones}")