Initial Commit
This commit is contained in:
parent
7b49daf267
commit
5d80470277
@ -1,5 +1,7 @@
|
||||
class product:
|
||||
def __init__(self, name: str, price: float, quantity: int = 1):
|
||||
def __init__(self, name: str, price: float, quantity = 0):
|
||||
assert price >= 0, "Price must be non-negative"
|
||||
assert quantity >= 0, "Quantity must be non-negative"
|
||||
self.name = name
|
||||
self.price = price
|
||||
self.quantity = quantity
|
||||
@ -13,7 +15,8 @@ class product:
|
||||
|
||||
|
||||
# Example usage:
|
||||
product1 = product("Laptop", 1999.99, 1)
|
||||
|
||||
product1 = product("Laptop", 1999.99, -1)
|
||||
print(product1.display_info()) # Output: Item: Laptop, Price: $1999.99
|
||||
print(product1.calculate_total_price()) # Output: 3999996.0001
|
||||
product2 = product("Smartphone", 799.99, 3)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user