-
Notifications
You must be signed in to change notification settings - Fork 113
/
Copy pathmain.py
68 lines (44 loc) · 1.46 KB
/
main.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
from abc import ABCMeta, abstractmethod
class Section(metaclass=ABCMeta):
@abstractmethod
def describe(self):
pass
class PersonalSection(Section):
def describe(self):
print('Personal Section')
class AlbumSection(Section):
def describe(self):
print('Album Section')
class PatentSection(Section):
def describe(self):
print('Patent Section')
class PublicationSection(Section):
def describe(self):
print('Publication Section')
class Profile(metaclass=ABCMeta):
def __init__(self):
self.sections = list()
self.create_profile()
@abstractmethod
def create_profile(self):
pass
def get_sections(self):
return [type(s).__name__ for s in self.sections]
def add_section(self, section):
self.sections.append(section)
class Linkedin(Profile):
def create_profile(self):
self.add_section(PersonalSection())
self.add_section(PatentSection())
self.add_section(PublicationSection())
class Facebook(Profile):
def create_profile(self):
self.add_section(PersonalSection())
self.add_section(AlbumSection())
if __name__ == '__main__':
linkedin = Linkedin()
facebook = Facebook()
print('Creating Profile...', type(linkedin).__name__)
print('Profile has sections --', linkedin.get_sections())
print('Creating Profile...', type(facebook).__name__)
print('Profile has sections --', facebook.get_sections())