-
Notifications
You must be signed in to change notification settings - Fork 5
/
account_6_corrected_premium.py
53 lines (36 loc) · 1.38 KB
/
account_6_corrected_premium.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from abc import ABC, abstractmethod
class Account(ABC):
"""Model a user account on a site or app."""
def __init__(self, username, password=""):
self.username = username
self._store_password(password)
def welcome_user(self):
print(f"Welcome to the site, {self.username}!")
@abstractmethod
def close_account(self):
pass
def _store_password(self, password):
print(f"Stored password for {self.username}.")
class FreeAccount(Account):
def welcome_user(self):
super().welcome_user()
print("You'll have limited access on a free account.")
class StandardAccount(Account):
def welcome_user(self):
super().welcome_user()
print("You have access to all features on the site.")
class PremiumAccount(Account):
def welcome_user(self):
super().welcome_user()
print("Thank you for supporting us at this level!")
def close_account(self):
# Query user about exactly what they want.
# Flag appropriate data for deletion.
# Flag appropriate data for preservation.
# Take care of refunds appropriately.
# Confirm account closure.
print("We have closed your Premium account.")
print(" Thank you for your involvement with us.")
if __name__ == "__main__":
account = PremiumAccount("birdie")
account.welcome_user()