-
Notifications
You must be signed in to change notification settings - Fork 2
/
interview.py
101 lines (64 loc) · 2.72 KB
/
interview.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# update is a hashMap(key = field, value = hashMap(key=value=stored_info))
# user A: Kevin J Lam. -> Kevin J
# candidate:
# location:
# email: [email protected]
class update(object):
def __init__(self, user_id):
self.user_id = user_id
self.deleted = dict()
self.updated = dict()
def delte_certain_info(self, field, info):
if (not field in self.deleted.keys()):
self.deleted[field] = {}
self.deleted[field][info] = info
def update_certain_info(self, field, info):
if (not field in self.updated.keys()):
self.updated[field] = {}
self.updated[field][info] = info
def revise_certain_info(self, field, before, after):
if (not field in self.updated.keys()):
self.updated[field] = {}
self.updated[field][before] = after
# info can be dict, string, list of dict
def deleted_certain_info_by_index(self, field, info, index):
if (not field in self.deleted.keys()):
self.deleted[field] = {}
if type(self.deleted[filed][index]) is dict:
class demenstration(object):
def __init__(self, user_id, original, difference):
self.user_id = user_id
self.original = original
self.difference = difference
self.fields = ["email"]
def show_content(self):
for field in self.fields:
original_ = self.original[field]
updated = self.difference.updated[field]
deleted = self.difference.deleted[field]
self.show_individual_content(original_, updated, deleted)
def show_individual_content(self, original, updated, deleted):
for deleted_ in deleted:
print(deleted_)
del(original[deleted_])
for updated_ in updated:
print(updated_)
if (updated_ in original.keys()):
del(original[updated_])
original[updated[updated_]] = updated[updated_]
print(original)
#dict() key=field value:list of object/string/dict
profile = dict() #default
profile["email"] = dict()
profile["email"]["[email protected]"] = "[email protected]"
profile["email"]["[email protected]"] = "[email protected]"
profile["experience"] = []
profile["experience"].append{"company":"Google", "title":"Software engineer"}
profile["experience"].append{"company":"Amazon", "title":"Manager"}
update_ = update("uid00001")
update_.delte_certain_info("email", "[email protected]")
update_.update_certain_info("email", "[email protected]")
update_.revise_certain_info("email", "[email protected]", "[email protected]")
# update_.revise_certain_info("experience", )
board = demenstration("uid00001", profile, update_)
board.show_content()