-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathOOPS_7.py
46 lines (31 loc) · 1.17 KB
/
OOPS_7.py
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
class Employee:
no_of_leaves = 8
def __init__(self, aname, asalary, arole):
self.name = aname
self.salary = asalary
self.role = arole
def printdetails(self):
return f"The Name is {self.name}. Salary is {self.salary} and role is {self.role}"
@classmethod
def change_leaves(cls, newleaves):
cls.no_of_leaves = newleaves
@classmethod
def from_dash(cls, string):
return cls(*string.split("-"))
@staticmethod
def printgood(string):
print("This is good " + string)
class Programmer(Employee):
no_of_leaves = 56
def __init__(self, aname, asalary, arole, languages):
self.name = aname
self.salary = asalary
self.role = arole
self.languages = languages
def printprog(self):
return f"The Programmer's Name is {self.name}. Salary is {self.salary} and role is {self.role}.The languages are {self.languages}"
harry = Employee("Harry", 255, "Instructor")
rohan = Employee("Rohan", 455, "Student")
shubham = Programmer("Shubham", 555, "Programmer", ["python"])
karan = Programmer("Karan", 777, "Programmer", ["python", "Cpp"])
print(karan.no_of_holiday)