diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/friend-group.iml b/.idea/friend-group.iml new file mode 100644 index 0000000..d0876a7 --- /dev/null +++ b/.idea/friend-group.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..2cf3496 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,715 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..7e83473 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..ed2824e --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/group.py b/group.py index e2ec347..f2644aa 100644 --- a/group.py +++ b/group.py @@ -1,5 +1,35 @@ """An example of how to represent a group of acquaintances in Python.""" # Your code to go here... +def bidirectionalset(person1, person2, relationtype): + person2.relationship[relationtype].append(person1.name) +class Person: + def __init__(self, name ,age, job): + self.name = name + self.age = age + self.job = job + self.relationship = {'partner':[],'landlord':[],'friend':[],'cousin':[]} -my_group = + def set_relation(self, person,relationtype): + self.relationship[relationtype].append(person.name) + bidirectionalset(self,person,relationtype) +jill = Person('Jill',26,'biologist') +zalika = Person('Zalika',28,'artist') +john = Person('John',27,'writer') +nash = Person('Nash',34,'chef') +# person1 = Person('YihanZhang',22, 'Student') +# person2 = Person('LongwenHu',22,'Student') +# person1.set_relation(person2,'partner') +jill.set_relation(zalika,'friend') +jill.set_relation(john,'partner') +nash.set_relation(john,'cousin') +nash.set_relation(zalika,'landlord') +print(jill.relationship) +print(zalika.relationship) +print(john.relationship) +print(nash.relationship) +# def person(name, age, job): +# +# return {'Name':name, 'Age':age, 'Job':job} +# +# print(my_group =[person("YihanZhang,22,Studnet"),person("LongwenHu,22,Studnet")])