-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathemployee_increment.py
More file actions
47 lines (36 loc) · 1.19 KB
/
employee_increment.py
File metadata and controls
47 lines (36 loc) · 1.19 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
class Employee():
# pass
increment = 1.5
count_instance = 0
def __init__(self,fname,lname,post,salary):
self.fname = fname
self.lname= lname
self.post = post
self.salary = salary
def increase(self):
self.salary = self.salary * Employee.increment
# @classmethod
# def count_instance(cls):
# return f"you have created {cls.count_instance} instance of Employee class"
@classmethod
def from_str(cls, emp_string):
fname,lname,post,salary = emp_string.split("-")
return cls(fname,lname,post,salary)
# emp1 and emp2 is an argument
emp1 = Employee("vikas","jaiswal","developer", 22000)
emp2= Employee("aditya","gautam", "manager", 20000)
class Programmer(Employee):
# pass
def __init__(self, fname,lname,post,salary,proglang,exp):
super().__init__(fname,lname,post,salary)
self.proglang = proglang
self.exp = exp
emp4 = Programmer("vikas","jaiswal","programmer",50000,"python","1year")
print(emp1.salary)
# emp1.increase()
print(emp1.salary)
emp3 = Employee.from_str("ambuj-tripathi-HR-25000")
print(emp3.fname)
print(emp3.salary)
print(emp4.post)
# print(Employee.count_instance())