At Westonci.ca, we provide reliable answers to your questions from a community of experts. Start exploring today! Experience the ease of finding reliable answers to your questions from a vast community of knowledgeable experts. Get detailed and accurate answers to your questions from a dedicated community of experts on our Q&A platform.
Sagot :
Answer:
Explanation:
The following code is written in Python and creates a class called customer which holds the customers name, purchase history amount, and current total. It also has 3 functions, a constructor that takes the customer name as a parameter. The add_to_cart function which increases the amount of the current total. And finally the checkout function which applies the available coupon and resets the variables if needed, as well as prints the info the to screen.
class Customer():
customer = ""
purchased_history = 0
current_total = 0
def __init__(self, name):
self.customer = name
def add_to_cart(self, amount):
self.current_total += amount
def checkout(self):
if self.purchased_history >= 100:
self.current_total *= 0.90
self.purchased_history = 0
else:
self.purchased_history += self.current_total
print(self.customer + " current total is: $" + str(self.current_total))
self.current_total = 0
We appreciate your visit. Hopefully, the answers you found were beneficial. Don't hesitate to come back for more information. We hope our answers were useful. Return anytime for more information and answers to any other questions you have. We're here to help at Westonci.ca. Keep visiting for the best answers to your questions.