-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathItem.py
More file actions
21 lines (17 loc) · 704 Bytes
/
Item.py
File metadata and controls
21 lines (17 loc) · 704 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class Item:
# Constructor.
def __init__(self, name, price, quantity):
self.name = name
self.price = price
self.quantity = quantity
# Help with equality comparison.
def __eq__(self, other):
if not isinstance(other, Item):
return False
return self.name == other.name
# Help with less than comparison.
def __lt__(self, other):
return self.name < other.name
#Help with pretty printing the object.
def __str__(self):
return f"Item Name:{self.name}\nItem Price:{self.price}\nItem Quantity:{self.quantity}"