Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
umitozmen committed Dec 7, 2020
1 parent cc4e16b commit 414a2b3
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions week09/refactoring/initial_person_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def add_connection(self, person, relation):

def forget(self, person):
"""Removes any connections to a person"""
pass
self.connections.pop(person,None)


def average_age(group):
Expand All @@ -28,13 +28,22 @@ def average_age(group):
if __name__ == "__main__":
# ...then create the group members one by one...
jill = Person("Jill", 26, "biologist")
john = Person("John", 27, "writer")
zalika = Person("Zalika", 28, "artist")
nash = Person("Nash", 34, "chef")

# ...then add the connections one by one...
# Note: this will fail from here if the person objects aren't created
jill.add_connection(zalika, "friend")

jill.add_connection(john, "partner")
john.add_connection(jill, "partner")
zalika.add_connection(jill, "friend")
nash.add_connection(john, "cousin")
nash.add_connection(zalika, "landlord")

# ... then forget Nash and John's connection
nash.forget(john)

# Then create the group
my_group = {jill, zalika, john, nash}

Expand Down

0 comments on commit 414a2b3

Please sign in to comment.