From edc664b5ed33ddeb4a7bc588aff6c523e94e1882 Mon Sep 17 00:00:00 2001 From: cheeks <134818917+leftovertoast@users.noreply.github.com> Date: Sun, 2 Mar 2025 23:29:14 +0000 Subject: [PATCH] Completed 9-11 Imported Admin --- Chapter_09/9-11_imported_admin.py | 9 ++++ .../administration.cpython-312.pyc | Bin 0 -> 3276 bytes Chapter_09/administration.py | 45 ++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 Chapter_09/9-11_imported_admin.py create mode 100644 Chapter_09/__pycache__/administration.cpython-312.pyc create mode 100644 Chapter_09/administration.py diff --git a/Chapter_09/9-11_imported_admin.py b/Chapter_09/9-11_imported_admin.py new file mode 100644 index 0000000..1d45429 --- /dev/null +++ b/Chapter_09/9-11_imported_admin.py @@ -0,0 +1,9 @@ +# Exercise 9-11 Imported Admin +# Learning Objective: Import multiple classes from one module. + +from administration import Users, Admin, Privileges + +george = Admin("George", "Costanza", "9/23/1959", "NY", "Black") +george.privileges.privileges = ["can add post", "can delete post", "can ban user", "can unban user", "can create user", "can delete user", "can modify site contents"] +george.describe_user() +george.privileges.show_privileges() \ No newline at end of file diff --git a/Chapter_09/__pycache__/administration.cpython-312.pyc b/Chapter_09/__pycache__/administration.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..50314c4adb8a2d8b5c850268c964100971a509d9 GIT binary patch literal 3276 zcmZ`*U1$|Y6rTM{HrM?5Zxb~WtJSL}ks`FIZLC!*N(tgms{vUyyOZ2aZ|+`a_NsSD z!G}O&QEDGb(u&kR70HW*LVZ*ySm?{OXbl%13hhIEi(W`c{=b6 zMrO5mrkZa^Haf9F`BUOSX)AQ52_r*_ONLZenIuD+3p$5%R|9IeplhhXHGnpvmZEW7 zFfJT0x6;rc+^Tc}$TXQyCWuuLPN*;{Z$~CH7{v!5WI~5gY$S{f80qDOE@~+|f#lVs z7Iq)Zc!6i9y^v9~f*$7nh?i#cjLkiJIL*W(Ts@dq# zBCrEiOr&g&TaKUhd9gL^k9r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2$_vofXda!q0E^N0C?+OfKlvi*Tpnq9#kQR zN`ny0xHp^&nCKg4@ECIiR=w`ES8TE@nVps;@Nm(??|kHD z^nchYH?1VyR^SN?#|s(x3ypWpH8UO8PTtUN9KU(!o_XM5$Hpt$E6KQcP>U_`t`1A5 zEi0*Td!% literal 0 HcmV?d00001 diff --git a/Chapter_09/administration.py b/Chapter_09/administration.py new file mode 100644 index 0000000..096cf20 --- /dev/null +++ b/Chapter_09/administration.py @@ -0,0 +1,45 @@ +class Users: + def __init__(self, first_name, last_name, dob, state, hair_color): + """Initialize User Profile variables""" + self.first_name = first_name + self.last_name = last_name + self.dob = dob + self.state = state + self.hair_color = hair_color + self.login_attempts = 0 + + def describe_user(self): + """Prints descriptions of user based on inputs""" + print(f"{self.first_name} {self.last_name} was born on {self.dob}, they live in {self.state} and they have {self.hair_color} hair") + + def greet_user(self): + """Prints personalized greeting to user specified""" + print(f"Welcome to this python program, {self.first_name} {self.last_name}!") + + def increment_login_attempts(self): + """Increments Login Attempts by one""" + self.login_attempts += 1 + + def reset_login_attempts(self): + """Resets login attempts to zero""" + self.login_attempts = 0 + +class Privileges: + def __init__(self, privileges=[]): + """Create separate class for privileges """ + self.privileges = privileges + + def show_privileges(self): + """ Print Privileges list """ + print(f"This user has the following privileges:\n") + if self.privileges: + for privilege in self.privileges: + print(f" - {privilege}") + else: + print(" - This user has no privileges.") + +class Admin(Users): + def __init__(self, first_name, last_name, dob, state, hair_color): + """ Initialize Users the add sepeicifc Admin attributes/methods """ + super().__init__(first_name, last_name, dob, state, hair_color) + self.privileges = Privileges() \ No newline at end of file