-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdictionaryy.py
More file actions
43 lines (33 loc) · 1.21 KB
/
Copy pathdictionaryy.py
File metadata and controls
43 lines (33 loc) · 1.21 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
class Employee:
def __init__(self, name, emp_id, email_id):
self.__name=name
self.__emp_id=emp_id
self.__email_id=email_id
def get_name(self):
return self.__name
def get_emp_id(self):
return self.__emp_id
def get_email_id(self):
return self.__email_id
class OrganizationDirectory:
def __init__(self,emp_list):
self.__emp_list=emp_list
def lookup(self,key_name):
result_list=[]
for emp in self.__emp_list:
if(key_name in emp.get_name()):
result_list.append(emp)
self.display(result_list)
return result_list
def display(self,result_list):
print("Search results:")
for emp in result_list:
print(emp.get_name()," ", emp.get_emp_id()," ",emp.get_email_id())
emp1=Employee("Kevin",24089, "Kevin_xyz@organization.com")
emp2=Employee("Jack",56789,"Jack_xyz@organization.com")
emp3=Employee("Jackson",67895,"Jackson_xyz@organization.com")
emp4=Employee("Henry Jack",23456,"Jacky_xyz@organization.com")
emp_list=[emp1,emp2,emp3,emp4]
org_dir=OrganizationDirectory(emp_list)
#Search for an employee
org_dir.lookup("Jack")