Created
October 8, 2020 07:01
-
-
Save sevperez/9c8fd22fcc5a03c5c6d3e468f8e22892 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Receipt: | |
def __init__(self, item, cost): | |
self.item = item | |
self.cost = cost | |
def receipt_msg(self): | |
return f"{self.item}, ${round(self.cost, 2)}" | |
def deliver(self): | |
msg = self.receipt_msg() | |
print(f"Printing receipt... {msg}") | |
class EmailReceipt(Receipt): | |
def __init__(self, item, cost, customer_email): | |
super().__init__(item, cost) | |
self.customer_email = customer_email | |
def deliver(self): | |
msg = self.receipt_msg() | |
print(f"Emailing receipt to [{self.customer_email}]... {msg}") | |
regular_receipt = Receipt("Subscription", 120) | |
regular_receipt.deliver() | |
# Printing receipt... Subscription, $120 | |
paperless_receipt = EmailReceipt("Subscription", 120, | |
"charles@diffengine.ai") | |
paperless_receipt.deliver() | |
# Emailing receipt to [charles@diffengine.ai]... Subscription, $120 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment