Skip to content

Instantly share code, notes, and snippets.

@huytung228
Created July 20, 2021 03:08
Show Gist options
  • Save huytung228/77f6afd095da3c4a07e8754689118fde to your computer and use it in GitHub Desktop.
Save huytung228/77f6afd095da3c4a07e8754689118fde to your computer and use it in GitHub Desktop.
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