Observer pattern solution in Clear category for Party Invitations by martin.pilka
def __init__(self, name):
self._name = name
self._invitation = 'No party...'
def invite(self, invitation):
self._invitation = invitation
Class Friend should have the show_invite() method which returns the string with the last invite that the
person has received with the right place, day and time. The right place - is the 'place' which is given
to the Party instance in the moment of creation. If the person didn't get any invites, this method should
return - "No party..."
In this mission you could use the Observer design pattern.
def __init__(self, place):
self._place = place
self._observers = 
def add_friend(self, observer: Friend):
Add friend 'name' to the list of the 'observers' (people, which will get the invitations, when the new party is
def del_friend(self, observer: Friend):
Remove 'friend' from the 'observers' list
def send_invites(self, time):
Send the invites with the right day and time to the each person on the list of 'observers'
for observer in self._observers:
Feb. 6, 2019