-
Notifications
You must be signed in to change notification settings - Fork 0
/
Employee.py
59 lines (45 loc) · 1.58 KB
/
Employee.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from typing import Dict, Any
class Employee(object):
__empCount = 0
names_salaries: Dict[Any, Any] = {}
def __init__(self, name, salary):
self.name = name
self.salary = salary
Employee.names_salaries[name] = salary
self.__empCount += 1
def setSalary(self, newSalary):
self.salary = newSalary
def getSalary(self, getSalary):
return self.salary
def getEmpCount(self):
return self.empCount
def fireEmployee(self, instance):
try:
if isinstance(instance, str):
del Employee.names_salarie[instance]
elif isinstance(instance, int):
del Employee.names_salaries[instance]
elif isinstance(instance, list):
for name in list:
del Employee.names_salaries[name]
Employee.__empCount__ -= 1
except:
raise Exception("Please enter a valid name or names")
def goBankrupt(self):
Employee.names_salaries.clear()
Employee.__empCount__ = 0
@staticmethod
def getAllEmpInfo():
return Employee.names_salaries
class Engineer(Employee):
__names_salaries_Engineer: Dict[Any, Any] = {}
__engineerCount = 0
def __init__(self,name,salary):
super()
Engineer.names_salaries[name] = salary
Engineer.__engineerCount +=1
def __str__(self):
return "This is a subclass of Employee"
@staticmethod
def getAllEngInfo():
return Engineer.__names_salaries_Engineer