· 7 years ago · May 12, 2019, 08:38 AM
1class Employe:
2 no_of_emp = 0
3 raise_amount = 2.5
4 def __init__(self, fname, lname, pay):
5 self.first = fname
6 self.last = lname
7 self.pay = pay
8
9 Employe.no_of_emp += 1
10
11 def name(self):
12 self.mail = self.first + '@gmail.com'
13 # return ('{} {}'.format(self.first, self.last))
14 return ('{}'.format(self.mail))
15
16
17 def apply(self):
18 self.pay = self.pay * self.raise_amount
19
20 @classmethod # is used to set value through obj
21 def chng_raise_amnt(cls, amount):
22 cls.raise_amount = amount
23
24 @classmethod
25 def form_str(cls, emp_str):
26 fn, ln, amn = emp_str.split('-')
27 return cls(fn,ln,amn)
28
29
30
31emp_1 = Employe('riju', 'chowdhury', '3000')
32# emp_1.apply()
33# emp_1.pay
34
35emp_str_1 = 'samrat-mitra-6000'
36new_emp_1 = Employe.form_str(emp_str_1)
37
38print(new_emp_1.name())
39
40# emp_1.chng_raise_amnt(3.09)
41
42# print(Employe.raise_amount)
43# print(emp_1.raise_amount)
44# print(emp_1.raise_amount)