-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclass_2methods.py
More file actions
34 lines (26 loc) · 796 Bytes
/
Copy pathclass_2methods.py
File metadata and controls
34 lines (26 loc) · 796 Bytes
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
class Employee:
raise_amount = 2.0
emp_count = 0
def __init__(self, first, last, pay):
self.first = first
self.last = last
self.pay = pay
self.email = first + '.' + last + '@company.com'
Employee.emp_count += 1
def fullname(self):
return '{} {}'.format(self.first, self.last)
def pay_raise(self):
self.pay = int(self.pay * self.raise_amount)
@classmethod
def set_raise_amt(cls, amount):
cls.raise_amount = amount
emp1 = Employee('vino', 'anto', 60000)
emp2 = Employee('Shan', 'vino', 70000)
Employee.set_raise_amt(3)
print(Employee.raise_amount)
print(emp1.pay)
emp1.pay_raise()
print(emp1.pay)
# print(emp2.email)
# print(emp1.fullname())
# Regular methjos to a class mehod by adding decorator.