-
Notifications
You must be signed in to change notification settings - Fork 56
/
prototype.py
68 lines (55 loc) · 1.95 KB
/
prototype.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
import copy
class WorkExperience:
def __init__(self):
self.company = ""
self.time_area = ""
class Resume:
def __init__(self, n):
self.name = n
self.work_experience = WorkExperience()
def set_personal_info(self, s, a):
self.sex = s
self.age = a
def set_work_experience(self, c, ta):
self.work_experience.company = c
self.work_experience.time_area = ta
def print_resume(self):
print self.name + ", " + self.sex + ", " + self.age + ", " \
+ self.work_experience.company + " : " + self.work_experience.time_area
def clone(self):
new_resume = copy.deepcopy(self)
new_resume.work_experience = copy.deepcopy(self.work_experience)
return new_resume
if __name__ == "__main__":
resume1 = Resume("Bob")
resume1.set_personal_info("M", "24")
resume1.set_work_experience("Google", "2015")
resume2 = resume1
resume2.set_personal_info("F", "22")
resume2.set_work_experience("Twitter", "2015")
resume1.print_resume()
resume2.print_resume()
resume1 = Resume("Bob")
resume1.set_personal_info("M", "24")
resume1.set_work_experience("Google", "2015")
resume2 = copy.copy(resume1)
resume2.set_personal_info("F", "22")
resume2.set_work_experience("Twitter", "2015")
resume1.print_resume()
resume2.print_resume()
resume1 = Resume("Bob")
resume1.set_personal_info("M", "24")
resume1.set_work_experience("Google", "2015")
resume2 = copy.deepcopy(resume1)
resume2.set_personal_info("F", "22")
resume2.set_work_experience("Twitter", "2015")
resume1.print_resume()
resume2.print_resume()
resume1 = Resume("Bob")
resume1.set_personal_info("M", "24")
resume1.set_work_experience("Google", "2015")
resume2 = resume1.clone()
resume2.set_personal_info("F", "22")
resume2.set_work_experience("Twitter", "2015")
resume1.print_resume()
resume2.print_resume()