Created
July 20, 2021 03:08
-
-
Save huytung228/77f6afd095da3c4a07e8754689118fde 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 Employee: | |
raise_amount = 1.05 | |
num_of_emps = 0 | |
def __init__(self, first, last, pay): | |
self.first = first | |
self.last = last | |
self.pay = pay | |
self.email = first+'.'+last+'@company.com' | |
Employee.num_of_emps += 1 | |
def fullname(self): | |
return f"{self.first} {self.last}" | |
def apply_raise(self): | |
# access class variables can perform by self or Employee | |
# self.pay = int(self.pay * self.raise_amount) | |
self.pay = int(self.pay * Employee.raise_amount) | |
e1 = Employee('Le', 'Huy Tung', 50000) | |
e2 = Employee('Mai', 'Thi Dinh', 60000) | |
print(Employee.num_of_emps) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment